Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3357936
D4393.id14069.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4393.id14069.diff
View Options
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
@@ -47,4 +47,41 @@
return self;
}
+- (void)writeMessage:(NSString *)message {
+ if ([message containsString:messageSeparator]) {
+ 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:[messageSeparator stringByAppendingString: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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 2:33 AM (1 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578046
Default Alt Text
D4393.id14069.diff (1 KB)
Attached To
Mode
D4393: Implement write operation for flat-file based message storage
Attached
Detach File
Event Timeline
Log In to Comment