mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-09 06:46:37 +08:00
fix media workflows and download organization
This commit is contained in:
@@ -28,6 +28,7 @@ var ErrUnsupportedOrganizeSource = errors.New("source is not a supported video f
|
||||
|
||||
const (
|
||||
organizeSkipAlreadyOrganized = "already organized"
|
||||
organizeSkipActiveDownload = "active download"
|
||||
organizeSkipDuplicateLibrary = "duplicate in library"
|
||||
organizeSkipTargetExists = "target file exists"
|
||||
organizeSkipSampleClip = "sample/trailer clip"
|
||||
@@ -60,11 +61,18 @@ func (o *OrganizerService) OrganizeDirectory(ctx context.Context, opts OrganizeO
|
||||
mode := o.resolveTransferMode(ctx, opts.TransferMode)
|
||||
res := &OrganizeResult{SourcePath: source, DestPath: dest, DryRun: opts.DryRun}
|
||||
metadataCache := map[string]*Match{}
|
||||
activeDownloads := o.newActiveDownloadGuard(ctx)
|
||||
if !info.IsDir() {
|
||||
ext := strings.ToLower(filepath.Ext(source))
|
||||
if _, ok := videoExtensions[ext]; !ok {
|
||||
return nil, fmt.Errorf("%w: %s", ErrUnsupportedOrganizeSource, source)
|
||||
}
|
||||
if activeDownloads.contains(source) {
|
||||
res.Skipped++
|
||||
res.Items = append(res.Items, OrganizePreviewItem{Source: source, Action: "skip", Reason: organizeSkipActiveDownload})
|
||||
o.logOrganizeDirectoryResult("organize file finished", res, mode)
|
||||
return res, nil
|
||||
}
|
||||
if skipped, reason := shouldSkipOrganizeSourceVideo(source, filepath.Dir(source)); skipped {
|
||||
res.Skipped++
|
||||
res.Items = append(res.Items, OrganizePreviewItem{Source: source, Action: "skip", Reason: reason})
|
||||
@@ -97,6 +105,11 @@ func (o *OrganizerService) OrganizeDirectory(ctx context.Context, opts OrganizeO
|
||||
if _, ok := videoExtensions[ext]; !ok {
|
||||
return nil
|
||||
}
|
||||
if activeDownloads.contains(path) {
|
||||
res.Skipped++
|
||||
res.Items = append(res.Items, OrganizePreviewItem{Source: path, Action: "skip", Reason: organizeSkipActiveDownload})
|
||||
return nil
|
||||
}
|
||||
if skipped, reason := shouldSkipOrganizeSourceVideo(path, source); skipped {
|
||||
res.Skipped++
|
||||
res.Items = append(res.Items, OrganizePreviewItem{Source: path, Action: "skip", Reason: reason})
|
||||
|
||||
Reference in New Issue
Block a user