Skip to content

Commit

Permalink
fix extension case, optimize copy if source and target are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
askolesov committed Sep 30, 2024
1 parent cf9372e commit f83d749
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template: |-
{{- $mediaCreateDate := and (any .Exif.MediaCreateDate) (ne .Exif.MediaCreateDate "0000:00:00 00:00:00") | ternary .Exif.MediaCreateDate "" -}}
{{- $date := or $dateTimeOriginal $mediaCreateDate "1970:01:01 00:00:00" | toDate "2006:01:02 15:04:05" -}}
{{- $mimeType := .Exif.MIMEType | default "unknown/unknown" | splitList "/" | first -}}
{{$make}} {{$model}} ({{$mimeType}})/{{$date | date "2006"}}/{{$date | date "2006-01-02"}}/{{$date | date "2006-01-02_15-04-05"}}_{{.Hash.Md5Short}}{{.Fs.Ext}}
{{$make}} {{$model}} ({{$mimeType}})/{{$date | date "2006"}}/{{$date | date "2006-01-02"}}/{{$date | date "2006-01-02_15-04-05"}}_{{.Hash.Md5Short}}{{.Fs.Ext | lower}}
# skipPermissionDenied: Controls whether to skip files and directories with permission denied errors.
skipPermissionDenied: true
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import (
// - Performs the actual copy operation if all checks pass.
// The function respects dryRun and errorOnAction flags for safety and logging purposes.
func SmartCopyFile(log func(string, ...any), source, target string, dryRun, errorOnAction bool) error {
if source == target {
log("Skipping copy, source and target are the same: source=%s, target=%s", source, target)
return nil
}

sourceInfo, err := os.Stat(source)
if err != nil {
return fmt.Errorf("failed to stat source file: %w", err)
Expand Down

0 comments on commit f83d749

Please sign in to comment.