Fixed a bug due to some missing filepath.ToSlash calls in StepCreateFloppy.Add.

If backslashes were in a filename (such as when running from Windows),
    this would cause the backslashes to be included in the filenames in the
    created floppy disk which caused havoc when Windows tried to parse it.

Fixed a bug in fsDirectoryCache when using path.Clean() to normalize the
    input directory properly. This would cause an error where a new directory
    "." would be created instead of it correctly returning the root directory.

Fixes issue #3977.
This commit is contained in:
Ali Rizvi-Santiago 2016-10-11 19:16:26 -05:00 committed by Matthew Hooker
parent 1bc73cf448
commit 1347b11f06

View File

@ -222,7 +222,7 @@ func (s *StepCreateFloppy) Add(dircache directoryCache, src string) error {
return err
}
entry, err := d.AddFile(path.Base(src))
entry, err := d.AddFile(path.Base(filepath.ToSlash(src)))
if err != nil {
return err
}
@ -251,9 +251,9 @@ func (s *StepCreateFloppy) Add(dircache directoryCache, src string) error {
_, err = dircache(filepath.ToSlash(base))
return err
}
directory, filename := filepath.Split(pathname)
directory, filename := filepath.Split(filepath.ToSlash(pathname))
base, err := removeBase(basedirectory, directory)
base, err := removeBase(basedirectory, filepath.FromSlash(directory))
if err != nil {
return err
}
@ -337,7 +337,10 @@ func fsDirectoryCache(rootDirectory fs.Directory) directoryCache {
Input, Output, Error := make(chan string), make(chan fs.Directory), make(chan error)
go func(Error chan error) {
for {
input := path.Clean(<-Input)
input := <-Input
if len(input) > 0 {
input = path.Clean(input)
}
// found a directory, so yield it
res, ok := cache[input]