From 0069c48e7e9298936dc5494865d0a4f674d6b29a Mon Sep 17 00:00:00 2001 From: yoshnopa <40072150+yoshnopa@users.noreply.github.com> Date: Wed, 10 May 2023 03:37:01 +0200 Subject: [PATCH] Folder Gallery creation on a per folder basis (#3715) * GalleryInExClusion // Create Gallery from folder based on file, short description in setting * GalleryInExClusion // No Folderiteration, expansion of docs * GalleryInExClusion // Only accept lowercase files * GalleryInExClusion // Correct text in settings --- pkg/image/scan.go | 18 +++++++++++++++++- ui/v2.5/src/docs/en/Manual/Configuration.md | 12 ++++++++++++ ui/v2.5/src/locales/en-GB.json | 4 ++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pkg/image/scan.go b/pkg/image/scan.go index 4c5280f6b..20bd609dc 100644 --- a/pkg/image/scan.go +++ b/pkg/image/scan.go @@ -307,7 +307,23 @@ func (h *ScanHandler) getOrCreateGallery(ctx context.Context, f file.File) (*mod return h.getOrCreateZipBasedGallery(ctx, f.Base().ZipFile) } - if h.ScanConfig.GetCreateGalleriesFromFolders() { + // Look for specific filename in Folder to find out if the Folder is marked to be handled differently as the setting + folderPath := filepath.Dir(f.Base().Path) + + forceGallery := false + if _, err := os.Stat(filepath.Join(folderPath, ".forcegallery")); err == nil { + forceGallery = true + } else if !errors.Is(err, os.ErrNotExist) { + return nil, fmt.Errorf("Could not test Path %s: %w", folderPath, err) + } + exemptGallery := false + if _, err := os.Stat(filepath.Join(folderPath, ".nogallery")); err == nil { + exemptGallery = true + } else if !errors.Is(err, os.ErrNotExist) { + return nil, fmt.Errorf("Could not test Path %s: %w", folderPath, err) + } + + if forceGallery || (h.ScanConfig.GetCreateGalleriesFromFolders() && !exemptGallery) { return h.getOrCreateFolderBasedGallery(ctx, f) } diff --git a/ui/v2.5/src/docs/en/Manual/Configuration.md b/ui/v2.5/src/docs/en/Manual/Configuration.md index 99b00f219..ee5cd131a 100644 --- a/ui/v2.5/src/docs/en/Manual/Configuration.md +++ b/ui/v2.5/src/docs/en/Manual/Configuration.md @@ -36,6 +36,18 @@ exclude: _a useful [link](https://regex101.com/) to experiment with regexps_ +## Gallery Creation from Folders + +In the Library section you can find an option to create a gallery from each folder containing images. This will be applied on all libraries when activated, including the base folder of a library. + +If you wish to apply this on a per folder basis, you can create a file called **.nogallery** or **.forcegallery** in a folder that should act different than this global setting. + +This will either exclude the folder from becoming a gallery even if the setting is set, or create a gallery from the folder even if the setting is not set. + +The file will only be recognized if written in lower case letters. + +Files with a dot in front are handled as hidden in the Linux OS and Mac OS, so you will not see those files after creation on your system without setting your file manager accordingly. + ## Hashing algorithms Stash identifies video files by calculating a hash of the file. There are two algorithms available for hashing: `oshash` and `MD5`. `MD5` requires reading the entire file, and can therefore be slow, particularly when reading files over a network. `oshash` (which uses OpenSubtitle's hashing algorithm) only reads 64k from each end of the file. diff --git a/ui/v2.5/src/locales/en-GB.json b/ui/v2.5/src/locales/en-GB.json index e049b1792..7226bd4ba 100644 --- a/ui/v2.5/src/locales/en-GB.json +++ b/ui/v2.5/src/locales/en-GB.json @@ -283,7 +283,7 @@ "check_for_insecure_certificates_desc": "Some sites use insecure ssl certificates. When unticked the scraper skips the insecure certificates check and allows scraping of those sites. If you get a certificate error when scraping untick this.", "chrome_cdp_path": "Chrome CDP path", "chrome_cdp_path_desc": "File path to the Chrome executable, or a remote address (starting with http:// or https://, for example http://localhost:9222/json/version) to a Chrome instance.", - "create_galleries_from_folders_desc": "If true, creates galleries from folders containing images.", + "create_galleries_from_folders_desc": "If true, creates galleries from folders containing images by default. Create a File called .forcegallery or .nogallery in a folder to enforce/prevent this.", "create_galleries_from_folders_label": "Create galleries from folders containing images", "database": "Database", "db_path_head": "Database Path", @@ -1243,4 +1243,4 @@ "weight_kg": "Weight (kg)", "years_old": "years old", "zip_file_count": "Zip File Count" -} \ No newline at end of file +}