Remove unnecessary logic

This commit is contained in:
Dane Everitt 2020-07-15 19:24:13 -07:00
parent a4e6c4b701
commit ae46add8ef
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -744,24 +744,15 @@ func (fs *Filesystem) CompressFiles(dir string, paths []string) (os.FileInfo, er
return a.Create(d, context.Background()) return a.Create(d, context.Background())
} }
// DecompressFile decompresses an archive. // Decompress a file in a given directory by using the archiver tool to infer the file
func (fs *Filesystem) DecompressFile(dir, file string) error { // type and go from there.
// Clean the directory path where the contents of archive will be extracted to. func (fs *Filesystem) DecompressFile(dir string, file string) error {
safeBasePath, err := fs.SafePath(dir) source, err := fs.SafePath(filepath.Join(dir, file))
if err != nil { if err != nil {
return err return errors.WithStack(err)
} }
// Clean the full path to the archive which will be unarchived. dest := strings.TrimSuffix(source, filepath.Base(source))
safeArchivePath, err := fs.SafePath(filepath.Join(safeBasePath, file))
if err != nil {
return err
}
// Decompress the archive using it's extension to determine the algorithm. return archiver.Unarchive(source, dest)
if err := archiver.Unarchive(safeArchivePath, safeBasePath); err != nil {
return err
}
return nil
} }