Skip to content

Commit ea799e0

Browse files
Adding better error handling to AppleNote gunzip call so that notes with healthy compressed data will still process.
1 parent ae63a7e commit ea799e0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/AppleNote.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,12 @@ def decompress_data
329329
# Check for GZip magic number
330330
if is_gzip(@compressed_data)
331331
zlib_inflater = Zlib::Inflate.new(Zlib::MAX_WBITS + 16)
332-
@decompressed_data = zlib_inflater.inflate(@compressed_data)
332+
begin
333+
@decompressed_data = zlib_inflater.inflate(@compressed_data)
334+
rescue StandardError => error
335+
# warn "\033[101m#{error}\033[m" # Prettified colors
336+
@logger.error("AppleNote: Note #{@note_id} somehow tried to decompress something that was GZIP but had to rescue error: #{error}")
337+
end
333338
else
334339
@logger.error("AppleNote: Note #{@note_id} somehow tried to decompress something that was not a GZIP")
335340
end

lib/AppleNoteStore.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,12 @@ def rip_notes()
676676
"ZICCLOUDSYNCINGOBJECT.ZMODIFICATIONDATE1 >= ? AND " +
677677
"ZICCLOUDSYNCINGOBJECT.ZMODIFICATIONDATE1 <= ?"
678678
@database.execute(tmp_query, range_start_core, range_end_core) do |row|
679-
self.rip_note(row["ZNOTE"])
679+
begin
680+
self.rip_note(row["ZNOTE"])
681+
rescue StandardError => error
682+
# warn "\033[101m#{e}\033[m"
683+
@logger.error("AppleNoteStore: NoteStore tried to rip Note#{row["ZNOTE"]} but had to rescue error: #{error}")
684+
end
680685
end
681686
end
682687

0 commit comments

Comments
 (0)