Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3560146
D4392.id13926.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4392.id13926.diff
View Options
diff --git a/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm b/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm
new file mode 100644
--- /dev/null
+++ b/native/ios/Comm/TemporalMessageStorage/TemporalMessageStorage.mm
@@ -0,0 +1,50 @@
+#import "TemporalMessageStorage.h"
+#import "EncryptedFileUtils.h"
+#import "Logger.h"
+#import "NonBlockingLock.h"
+#import <string>
+
+int const randomFilesNumberThreshold = 20;
+NSString *const messageSeparator = @"\n";
+
+@implementation TemporalMessageStorage
+- (instancetype)init {
+ self = [self initAtDirectory:@"TemporalMessageStorage"
+ withMainStorage:@"mainStorage"
+ withLockName:@"group.app.comm/tmp_msg_sem"];
+ return self;
+}
+
+- (instancetype)initAtDirectory:(NSString *)directoryName
+ withMainStorage:(NSString *)mainStorageName
+ withLockName:(NSString *)lockName {
+ self = [super init];
+ if (self) {
+ NSURL *groupURL = [NSFileManager.defaultManager
+ containerURLForSecurityApplicationGroupIdentifier:@"group.app.comm"];
+ NSURL *directoryURL = [groupURL URLByAppendingPathComponent:directoryName];
+ NSString *directoryPath = directoryURL.path;
+
+ if (![NSFileManager.defaultManager fileExistsAtPath:directoryPath]) {
+ [NSFileManager.defaultManager createDirectoryAtPath:directoryPath
+ withIntermediateDirectories:NO
+ attributes:nil
+ error:nil];
+ }
+ NSString *mainStoragePath =
+ [directoryURL URLByAppendingPathComponent:mainStorageName].path;
+
+ if (![NSFileManager.defaultManager fileExistsAtPath:mainStoragePath]) {
+ [NSFileManager.defaultManager createFileAtPath:mainStoragePath
+ contents:nil
+ attributes:nil];
+ }
+ _directoryURL = directoryURL;
+ _directoryPath = directoryPath;
+ _mainStoragePath = mainStoragePath;
+ _lockName = lockName;
+ }
+ return self;
+}
+
+@end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 28, 7:11 AM (3 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2724548
Default Alt Text
D4392.id13926.diff (2 KB)
Attached To
Mode
D4392: Implement flat-file based message storage initialization
Attached
Detach File
Event Timeline
Log In to Comment