Don't scan zero length files or directories (#1779)

* Don't scan zero length files or directories
This commit is contained in:
WithoutPants 2021-09-27 16:49:30 +10:00 committed by GitHub
parent 479bd438df
commit 94d192b833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 15 deletions

View File

@ -83,6 +83,16 @@ func (j *ScanJob) Execute(ctx context.Context, progress *job.Progress) {
return stoppingErr
}
// #1756 - skip zero length files and directories
if info.IsDir() {
return nil
}
if info.Size() == 0 {
logger.Infof("Skipping zero-length file: %s", path)
return nil
}
if isGallery(path) {
galleries = append(galleries, path)
}
@ -401,11 +411,6 @@ func (t *ScanTask) scanGallery() {
// scan the zip files if the gallery has no images
scanImages = scanImages || images == 0
} else {
// Ignore directories.
if isDir, _ := utils.DirExists(t.FilePath); isDir {
return
}
checksum, err := t.calculateChecksum()
if err != nil {
logger.Error(err.Error())
@ -729,11 +734,6 @@ func (t *ScanTask) scanScene() *models.Scene {
return nil
}
// Ignore directories.
if isDir, _ := utils.DirExists(t.FilePath); isDir {
return nil
}
videoFile, err := ffmpeg.NewVideoFile(instance.FFProbePath, t.FilePath, t.StripFileExtension)
if err != nil {
logger.Error(err.Error())
@ -1059,11 +1059,6 @@ func (t *ScanTask) scanImage() {
// check for thumbnails
t.generateThumbnail(i)
} else {
// Ignore directories.
if isDir, _ := utils.DirExists(t.FilePath); isDir {
return
}
var checksum string
logger.Infof("%s not found. Calculating checksum...", t.FilePath)

View File

@ -22,6 +22,7 @@
* Added sv-SE language option. ([#1691](https://github.com/stashapp/stash/pull/1691))
### 🐛 Bug fixes
* Don't scan zero-length files. ([#1779](https://github.com/stashapp/stash/pull/1779))
* Accept svg files in file selector for tag images. ([#1778](https://github.com/stashapp/stash/pull/1778))
* Fix criteria being incorrectly applied when clicking back button. ([#1765](https://github.com/stashapp/stash/pull/1765))
* Show first page and fix order direction not being maintained when clicking on card popover button. ([#1765](https://github.com/stashapp/stash/pull/1765))