fix media workflows and download organization

This commit is contained in:
ShukeBta
2026-06-26 08:42:16 +08:00
parent 0da96f7e4e
commit 65adca04df
102 changed files with 4063 additions and 437 deletions
@@ -89,24 +89,42 @@ func (o *OrganizerService) organizeLibraryTargetScopeScore(libPath, destRoot, me
if libPath == "" || libPath == "." {
return 0, false
}
collectionRoot := organizeMediaCollectionRoot(destRoot)
if collectionRoot != "" && pathWithin(libPath, collectionRoot) && !o.organizeLibraryMatchesExpectedPhysicalRoot(libPath, collectionRoot, mediaType, category) {
return 0, false
}
if pathWithin(libPath, destRoot) || pathWithin(destRoot, libPath) {
return 8, true
}
if _, destCategory := o.mediaTypeForDirectoryCategory(filepath.Base(destRoot)); destCategory == "" {
if root := organizeMediaCollectionRoot(destRoot); root != "" && pathWithin(libPath, root) {
return o.organizeLibraryPhysicalRootScore(libPath, root, mediaType, category), true
if collectionRoot != "" && pathWithin(libPath, collectionRoot) {
return o.organizeLibraryPhysicalRootScore(libPath, collectionRoot, mediaType, category), true
}
return 0, false
}
if strings.EqualFold(filepath.Dir(libPath), filepath.Dir(destRoot)) {
return 4, true
}
if root := organizeMediaCollectionRoot(destRoot); root != "" && pathWithin(libPath, root) {
return o.organizeLibraryPhysicalRootScore(libPath, root, mediaType, category), true
if collectionRoot != "" && pathWithin(libPath, collectionRoot) {
return o.organizeLibraryPhysicalRootScore(libPath, collectionRoot, mediaType, category), true
}
return 0, false
}
func (o *OrganizerService) organizeLibraryMatchesExpectedPhysicalRoot(libPath, collectionRoot, mediaType, category string) bool {
if strings.TrimSpace(category) == "" {
return true
}
physicalRoot := o.categoryPhysicalRootDir(category)
if physicalRoot == "" {
physicalRoot = mediaTypeRootDir(mediaType)
}
if physicalRoot == "" {
return true
}
return pathHasDirectChild(libPath, collectionRoot, physicalRoot)
}
func (o *OrganizerService) organizeLibraryPhysicalRootScore(libPath, collectionRoot, mediaType, category string) int {
physicalRoot := o.categoryPhysicalRootDir(category)
if physicalRoot == "" {