Skip to content

AssetLoader panics when trying to open a file with no extension #576

@Matthew-Maclean

Description

@Matthew-Maclean

in 0.2.1, trying to open a file with no extension causes a panic somewhere in the asset loading pipeline, even when the asset loader used has an empty string in it's extensions(&self) -> &[&str]] value. Not all files have an extension, so it should be possible to open these files, even if it means creating your own AssetLoader. Below is the asset loader that doesn't work. I don't even think it runs, if I place a panic with a specific message in the from_bytes function, the other panics happen before.

#[derive(Default)]
struct Test;

impl AssetLoader<Test> for Test
{
    fn from_bytes(&self, _asset_path: &Path, bytes: Vec<u8>) -> Result<Test, Error>
    {
        Ok(Test)
    }

    fn extensions(&self) -> &[&str]
    {
        &[""]
    }
}

(as an aside, I think it should be possible to open files that don't match their loader's extensions, as some more general types could accept almost any type, like a loader for Vec<u8> or String)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsP-CrashA sudden unexpected crashS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    Status

    Assets-wide Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions