Skip to content

bug: CreateDirectoryDeep does not ensure the directory exists #231

Description

@techfg

CreateDirectoryDeep is expected to ensure a directory exists (or one is created) at the specified path. However, it only ensures that "something" exists at the path and does not verify that it is a directory as it does not inspect the FileInfo returned from os.Stat when err == nil.

This results in the calling function continuing to process and unexpectedly running into other issues. For example, during a retrieve, an error will eventually surface while unzipping an archive which would not make any sense to an end-user since they would never expect a file (SkuidSample_NW_OData.json) to be a directory as the message indicates.

As an aside, it also does not check that the error is os.ErrNotExist so if there was an error and it wasn't os.ErrNotExist, it will very likely fail again when it calls MkDirAll. While still an additional bug that should be addressed, in this case, it's actually a good thing since at least an error will be returned.

time="2024-09-27T04:47:56-07:00" level=warning msg="unable to open file in copytofile" error="open skuid-testsite/datasources/SkuidSample_NW_OData.json: not a directory"
time="2024-09-27T04:48:00-07:00" level=warning msg="Error with file creator: open skuid-testsite/datasources/SkuidSample_NW_OData.json: not a directory"
time="2024-09-27T04:48:02-07:00" level=warning msg="Error with UnzipArchive" error="open skuid-testsite/datasources/SkuidSample_NW_OData.json: not a directory" fileName=/tmp/Skuid-NLX1671952382 targetDirectoryFriendly=skuid-testsite
time="2024-09-27T04:48:02-07:00" level=error msg="Error Encountered During Run: \x1b[31mopen skuid-testsite/datasources/SkuidSample_NW_OData.json: not a directory\x1b[0m"

CreateDirectoryDeep should properly ensure that the directory exists (or is created) or return an error otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions