ZIP Files without subdirectories do not copy correctly
Expected Behavior
ZIP Files are extracted and mapped to the local file system as per their file table for all cases of directory support.
Actual Behavior
ZIP Files that do not start with a directory in their file table result in the last file in the file table being copied as a file as specified by the destination directory.
As per https://github.com/viant/afs/commit/21faa05491d949fd92f0e1b1988ee25614158dfc, this sets up a situation of a ZIP file with just 2 files, a.txt and b.txt, which is then requested to be unzipped as per expected behavior using afs.(*Service).Copy().
The result is that the specified directory is a file.
Based on initial debugging, this occurs if the first entry in the ZIP is not a directory.
https://github.com/viant/afs/blob/21faa05491d949fd92f0e1b1988ee25614158dfc/copy.go#L51-L56
In the case the resulting source.IsDir() is false, then mappedName is set, which alters behavior, specifically, it replaces the resulting name of the copied file.
https://github.com/viant/afs/blob/21faa05491d949fd92f0e1b1988ee25614158dfc/copy.go#L84-L96
For branch https://github.com/viant/afs/tree/issue-24-zip-error Converted manual run scripts to unit tests without file dependencies. https://github.com/viant/afs/blob/ee44867a4e800db341bc06eb8e8469becd81614e/zip/manager_test.go#L73
One of the crux issues is that the behavior for List() isn't particularly concrete depending on modifiers and implementation, particularly with the recursive option enabled.
- Should non-recursive
List()include the directory itself (i.e..)?- There is some behavior in the main Manager that handles this specially, and is why the ZIP behavior is weird.
- Should recursive
List()include directories as items? - Should ZIP file tables, which are not required to include directory entries, include directory entries?
- Should ZIP files, be recursive without the
List()recursion enabled, due to how file table prefixes work?