Skip to content

Commit a8a66ee

Browse files
Fixed ncc file not being generated when there was no change
Fixed error when ncc file did not exist. Now the bot sends the diff file without text.
1 parent 4b87238 commit a8a66ee

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NotifierBot/Sources/Notifier/Commands/DiffCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct DiffCommand: Command {
3131
return
3232
}
3333
// Send the diff file and the contents of the ncc file
34-
let nccInfo = try String(contentsOfFile: "\(mainDirectory!)/urlwatcher/images/\(name)/\(nccFile)")
34+
let nccInfo = try? String(contentsOfFile: "\(mainDirectory!)/urlwatcher/images/\(name)/\(nccFile)")
3535
JFUtils.sendImage(path: "\(mainDirectory!)/urlwatcher/images/\(name)/\(diffFile)", chatID: chatID, text: nccInfo)
3636
}
3737
}

urlwatcher/urlwatcher.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ function screenshotsMatch {
135135

136136
if [ "NCC" -lt "$NCC_THRESHOLD" ]; then
137137
# The screenshots do not match. The website has changed
138+
138139
# Write detailed NCC information to a file (and don't overwrite the diff file)
139140
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null > "$NCC_FILE"
140141

@@ -144,6 +145,9 @@ function screenshotsMatch {
144145
fi
145146
fi
146147

148+
# Write detailed NCC information to a file (and don't overwrite the diff file)
149+
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null > "$NCC_FILE"
150+
147151
# If statement above didn't exit, that means we have no mismatching hashes and therefore the screenshots match (return true)
148152
# In bash: 0 == true
149153
return 0
@@ -224,7 +228,7 @@ while IFS='' read -r line || [ -n "${line}" ]; do
224228

225229
# If the new screenshot is all black or all white (some display error), ignore it
226230
mean=$(convert latest.png -format "%[mean]" info:)
227-
if [ "$mean" == "0" || "$mean" == "65535" ]; then
231+
if [ "$mean" == "0" ] || [ "$mean" == "65535" ]; then
228232
rollBack
229233
# Skip this entry
230234
cd ../..

0 commit comments

Comments
 (0)