Skip to content

Commit aad3a61

Browse files
authored
Merge pull request #14 from nullable-eth/only-create-dir-for-txt
bug: only create directories on txt export
2 parents f3e651b + 7b8ad5c commit aad3a61

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

cmd/labelarr/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,25 @@ func handleNormalMode(cfg *config.Config, processor *media.Processor, movieLibra
283283
if err := exporter.FlushAll(); err != nil {
284284
fmt.Printf("❌ Failed to write export files: %v\n", err)
285285
} else {
286-
fmt.Printf("✅ Successfully wrote export files to library subdirectories\n")
287-
fmt.Printf("📊 Generated summary.txt with detailed statistics and file sizes\n")
286+
if cfg.ExportMode == "json" {
287+
fmt.Printf("✅ Successfully wrote export data to export.json\n")
288+
} else {
289+
fmt.Printf("✅ Successfully wrote export files to library subdirectories\n")
290+
fmt.Printf("📊 Generated summary.txt with detailed statistics and file sizes\n")
291+
}
288292
}
289293
} else {
290294
fmt.Printf("📭 No matching items found for export labels\n")
291295
// Still create empty files for each label in each library
292296
if err := exporter.FlushAll(); err != nil {
293297
fmt.Printf("❌ Failed to create export files: %v\n", err)
294298
} else {
295-
fmt.Printf("✅ Created empty export files in library subdirectories\n")
296-
fmt.Printf("📊 Generated summary.txt with export statistics\n")
299+
if cfg.ExportMode == "json" {
300+
fmt.Printf("✅ Created empty export.json file\n")
301+
} else {
302+
fmt.Printf("✅ Created empty export files in library subdirectories\n")
303+
fmt.Printf("📊 Generated summary.txt with export statistics\n")
304+
}
297305
}
298306
}
299307
}

internal/export/export.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ func (e *Exporter) SetCurrentLibrary(libraryName string) error {
9898
sanitizedName := sanitizeFilename(libraryName)
9999
e.currentLibrary = sanitizedName
100100

101-
// Create library-specific subdirectory if it doesn't exist
102-
libraryPath := filepath.Join(e.exportLocation, sanitizedName)
103-
if err := os.MkdirAll(libraryPath, 0755); err != nil {
104-
return fmt.Errorf("failed to create library directory %s: %w", libraryPath, err)
101+
// Only create library-specific subdirectory in txt mode
102+
if e.exportMode == "txt" {
103+
libraryPath := filepath.Join(e.exportLocation, sanitizedName)
104+
if err := os.MkdirAll(libraryPath, 0755); err != nil {
105+
return fmt.Errorf("failed to create library directory %s: %w", libraryPath, err)
106+
}
105107
}
106108

107109
// Initialize accumulated map for this library if it doesn't exist

0 commit comments

Comments
 (0)