From 94d192b83309cb336a0d13e4ba1e6d9b8f9961d1 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:49:30 +1000 Subject: [PATCH] Don't scan zero length files or directories (#1779) * Don't scan zero length files or directories --- pkg/manager/task_scan.go | 25 ++++++++----------- .../components/Changelog/versions/v0100.md | 1 + 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pkg/manager/task_scan.go b/pkg/manager/task_scan.go index f76f14497..bec812a7b 100644 --- a/pkg/manager/task_scan.go +++ b/pkg/manager/task_scan.go @@ -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) diff --git a/ui/v2.5/src/components/Changelog/versions/v0100.md b/ui/v2.5/src/components/Changelog/versions/v0100.md index 21e5ac4f6..d3a7dc0a6 100644 --- a/ui/v2.5/src/components/Changelog/versions/v0100.md +++ b/ui/v2.5/src/components/Changelog/versions/v0100.md @@ -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))