From afef7ebea0b1409e560547169fa2de7c35bc4008 Mon Sep 17 00:00:00 2001 From: Eli Jones Date: Thu, 2 May 2024 10:04:10 -0400 Subject: [PATCH] [2.5.1] adds a throttle for known "File already exists (for moving)." sentry warning. presumably the bug is related to https://github.com/onnela-lab/beiwe-ios/issues/63 --- Beiwe/Managers/DataStorageManager.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Beiwe/Managers/DataStorageManager.swift b/Beiwe/Managers/DataStorageManager.swift index b366d09..56b76fd 100644 --- a/Beiwe/Managers/DataStorageManager.swift +++ b/Beiwe/Managers/DataStorageManager.swift @@ -3,6 +3,8 @@ import IDZSwiftCommonCrypto import Security import Sentry +var FILE_WRITE_FILE_EXISTS_COUNTER = 0 + enum DataStorageErrors: Error { case cantCreateFile case notInitialized @@ -298,7 +300,11 @@ class DataStorageManager { sentry_warning("File not found (for moving).", shortenPath(src), crash:false) } catch CocoaError.fileWriteFileExists { // print("File already exists (for moving) \(shortenPath(dst)), giving up for now because that's crazy?") - sentry_warning("File already exists (for moving).", shortenPath(dst), crash:false) + // we are getting a huge number of these reported, so throttle by 10x? + FILE_WRITE_FILE_EXISTS_COUNTER += 1 + if FILE_WRITE_FILE_EXISTS_COUNTER % 10 == 0 { + sentry_warning("File already exists (for moving).", shortenPath(dst), crash:false) + } } catch CocoaError.fileWriteOutOfSpace { // print("Out of space (for moving) \(shortenPath(dst))") // sentry_warning("Out of space (for moving).", shortenPath(dst)) // never report out of space like this.