Skip to content

Commit 0753783

Browse files
Fixed repeated "Added ..." messages by now created a file ".added" if the entry was already announced as added
1 parent 128f186 commit 0753783

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

urlwatcher/Sources/urlwatcher/main.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,17 @@ for i in 0..<config.count {
9393
// Crop the screenshot
9494
try cropScreenshot(path: latestImage, area: entry.area)
9595

96-
// If there is no previous screenshot, we cannot compare anything
97-
guard fileManager.fileExists(atPath: oldImage) else {
96+
let addedPath = "\(entryPath)/.added"
97+
guard fileManager.fileExists(atPath: addedPath) else {
9898
// This is a new entry
9999
try notifyNew(entry: entry, file: latestImage)
100+
fileManager.createFile(atPath: addedPath, contents: nil)
101+
// Skip comparison
102+
return false
103+
}
104+
105+
// If there is no previous screenshot, we cannot compare anything
106+
guard fileManager.fileExists(atPath: oldImage) else {
100107
// Skip comparison
101108
return false
102109
}

0 commit comments

Comments
 (0)