mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-14 18:48:11 +02:00
7.4: never sort files that are still downloading
Files ending in .part, .crdownload or .download (any case), and a file next to its own unfinished download (Firefox's empty placeholder), are skipped before any pattern check, folder zipping or unzipping. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
234889ba6d
commit
4a52120b1a
5 files changed
+27
-9
No files matched your search
+19
-2
@@ -6,7 +6,7 @@ import shutil
|
||||
import time
|
||||
import toml
|
||||
|
||||
# Version = "7.3"
|
||||
# Version = "7.4"
|
||||
|
||||
ConfPath = "./GlobalConf.toml"
|
||||
|
||||
@@ -393,6 +393,20 @@ def FileInputValid(File, FilePath, ParentName):
|
||||
return False
|
||||
|
||||
|
||||
# Files that are still downloading (since 7.4): Firefox's .part, Chromium's .crdownload and Safari's .download.
|
||||
# SaraSortd never touches them, not even to check them against patterns.
|
||||
PartialDownloadSuffixes = (".part", ".crdownload", ".download")
|
||||
|
||||
|
||||
def IsPartialDownload(FilePath):
|
||||
if os.path.basename(FilePath).lower().endswith(PartialDownloadSuffixes):
|
||||
return True
|
||||
|
||||
# A file next to its own unfinished download, E.G. the empty "video.mp4" Firefox makes beside
|
||||
# "video.mp4.part" and fills in at the end. Moving it would break the download.
|
||||
return any(os.path.exists(FilePath + Suffix) for Suffix in PartialDownloadSuffixes)
|
||||
|
||||
|
||||
def IsCatchAll(Pattern):
|
||||
# A pattern made of only "*" takes any file.
|
||||
return Pattern != "" and set(Pattern) == {"*"}
|
||||
@@ -632,7 +646,7 @@ def Main():
|
||||
if len(GetConf("Unzip", OutDirConfPath) or []) >= 1:
|
||||
ZipTypes = GetConf("Unzip", OutDirConfPath)
|
||||
for OutputFile in os.listdir(OutputPath):
|
||||
if OutputFile.startswith("."):
|
||||
if OutputFile.startswith(".") or IsPartialDownload(f"{OutputPath}/{OutputFile}"):
|
||||
continue
|
||||
|
||||
for ZipType in ZipTypes:
|
||||
@@ -662,6 +676,9 @@ def Main():
|
||||
|
||||
for FileName in os.listdir(InputPath):
|
||||
FilePath = f"{InputPath}/{FileName}"
|
||||
if IsPartialDownload(FilePath):
|
||||
continue
|
||||
|
||||
if os.path.isdir(FilePath) and InputDirConf.get("SortDirs", 0) == 0:
|
||||
continue
|
||||
|
||||
|
||||
Reference in new issue
Block a user