Page MenuHomePhabricator

D4392.id13926.diff
No OneTemporary

D4392.id13926.diff

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

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)

Event Timeline