Page MenuHomePhabricator

D4393.id14167.diff
No OneTemporary

D4393.id14167.diff

diff --git a/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm b/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm
--- a/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm
+++ b/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm
@@ -46,4 +46,40 @@
return self;
}
+- (void)writeMessage:(NSString *)message {
+ if ([message containsString:encryptedDataSeparator]) {
+ comm::Logger::log(
+ "Messages containing separator not allowed. Skipping notification.");
+ return;
+ }
+
+ if (![NSFileManager.defaultManager fileExistsAtPath:self.mainStoragePath]) {
+ comm::Logger::log("Store not existing yet. Skipping notification");
+ return;
+ }
+
+ NSError *err = nil;
+ NonBlockingLock *lock = [[NonBlockingLock alloc] initWithName:self.lockName];
+ BOOL acquired = [lock tryAcquireLock:&err];
+ if (!acquired) {
+ NSString *randomPath =
+ [self.directoryURL URLByAppendingPathComponent:[NSUUID UUID].UUIDString]
+ .path;
+ [EncryptedFileUtils writeData:message toFileAtPath:randomPath error:nil];
+ comm::Logger::log(
+ "Failed to acquire lock. Details: " +
+ std::string([err.localizedDescription UTF8String]));
+ return;
+ }
+ [EncryptedFileUtils appendData:message
+ toFileAtPath:self.mainStoragePath
+ error:&err];
+ [lock releaseLock:nil];
+ if (err) {
+ comm::Logger::log(
+ "Failed to append message to storage. Details: " +
+ std::string([err.localizedDescription UTF8String]));
+ }
+}
+
@end

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 29, 5:27 PM (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597631
Default Alt Text
D4393.id14167.diff (1 KB)

Event Timeline