We should never ever overwrite files in package pool. #127

This commit is contained in:
Andrey Smirnov
2014-10-17 00:54:15 +04:00
parent 951b6e9004
commit 2a9871e2e9
+8 -9
View File
@@ -128,16 +128,15 @@ func (pool *PackagePool) Import(path string, hashMD5 string) error {
// unable to stat target location?
return err
}
}
} else {
// target already exists
if targetInfo.Size() != sourceInfo.Size() {
// trying to overwrite file?
return fmt.Errorf("unable to import into pool: file %s already exists", poolPath)
}
if targetInfo.Size() != sourceInfo.Size() {
// trying to overwrite file?
return fmt.Errorf("unable to import into pool: file %s already exists", poolPath)
}
if os.SameFile(targetInfo, sourceInfo) {
// Same file on the filesystem? Just skip it.
return err
// assume that target is already there
return nil
}
// create subdirs as necessary