Skip to content

Commit

Permalink
Make timestamps actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
quackduck committed Dec 25, 2022
1 parent 3b5c884 commit fd95a11
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions rem.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func trashFile(path string) {
return
}
toMoveTo = getTimestampedPath(toMoveTo, exists)
path = getTimestampedPath(path, existsInLog)
if flags.moveByCopyOk {
err = renameByCopyAllowed(path, toMoveTo)
} else {
Expand All @@ -273,7 +272,14 @@ func trashFile(path string) {
}

absPath, _ := filepath.Abs(path)
logFile[absPath] = toMoveTo // format is path where it came from ==> path in trash

// make sure there are no conflicts in the log
timestamped := getTimestampedPath(absPath, existsInLog)

if timestamped != absPath {
printIfNotQuiet("To avoid conflicts, " + color.YellowString(filepath.Base(absPath)) + " will now be called " + color.YellowString(filepath.Base(timestamped)))
}
logFile[timestamped] = toMoveTo // format is path where it came from ==> path in trash
setLogFile(logFile)
// if we've reached here, trashing is complete and successful
if flags.rmMode {
Expand Down Expand Up @@ -326,9 +332,6 @@ func getTimestampedPath(path string, existsFunc func(string) bool) string {
path = oldPath + " " + strconv.FormatInt(rand.Int63(), 10) // add random stuff at the end
}
}
if i != 0 {
printIfNotQuiet("To avoid conflicts, " + color.YellowString(oldPath) + " will now be called " + color.YellowString(path))
}
return path
}

Expand Down

0 comments on commit fd95a11

Please sign in to comment.