admin: Fix check file on disk for compressed files
This commit is contained in:
parent
407b67f4c2
commit
24686a6a24
2 changed files with 20 additions and 7 deletions
|
|
@ -392,7 +392,12 @@ func (f *EFile) GetDepends() ([]Flag, error) {
|
|||
|
||||
// CheckFileOnDisk recalculates the hash of the file on disk.
|
||||
func (f *EFile) CheckFileOnDisk() error {
|
||||
if _, size, err := checkFileHash(path.Join(FilesDir, f.Path), f.Checksum); err != nil {
|
||||
firstChecksum := f.Checksum
|
||||
if len(f.ChecksumShown) > 0 {
|
||||
firstChecksum = f.ChecksumShown
|
||||
}
|
||||
|
||||
if _, size, err := checkFileHash(path.Join(FilesDir, f.Path), firstChecksum); size > 0 && err != nil {
|
||||
return err
|
||||
} else if size == 0 {
|
||||
if _, _, err := checkFileHash(path.Join(FilesDir, f.Path+".gz"), f.Checksum); err != nil {
|
||||
|
|
@ -400,9 +405,17 @@ func (f *EFile) CheckFileOnDisk() error {
|
|||
} else {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Join(FilesDir, f.Path+".gz")); !os.IsNotExist(err) {
|
||||
if _, _, err = checkFileHash(path.Join(FilesDir, f.Path+".gz"), f.Checksum); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GunzipFileOnDisk gunzip a compressed file.
|
||||
|
|
|
|||
Reference in a new issue