Page MenuHomePhabricator

D4472.id14469.diff
No OneTemporary

D4472.id14469.diff

diff --git a/native/ios/Comm/TemporaryMessageStorage/TemporaryMessageStorage.mm b/native/ios/Comm/TemporaryMessageStorage/TemporaryMessageStorage.mm
--- a/native/ios/Comm/TemporaryMessageStorage/TemporaryMessageStorage.mm
+++ b/native/ios/Comm/TemporaryMessageStorage/TemporaryMessageStorage.mm
@@ -4,6 +4,12 @@
#import "NonBlockingLock.h"
#import <string>
+@interface TemporaryMessageStorage ()
+- (NSString *)_createNewStorage;
+- (NSString *)_getLockName:(NSString *)fileName;
+- (NSString *)_getPath:(NSString *)fileName;
+@end
+
@implementation TemporaryMessageStorage
- (instancetype)init {
@@ -40,4 +46,30 @@
return self;
}
+- (NSString *)_createNewStorage {
+ int64_t timestamp = (int64_t)[NSDate date].timeIntervalSince1970;
+ NSString *newStorageName = [NSString stringWithFormat:@"msg_%lld", timestamp];
+ NSString *newStoragePath =
+ [self.directoryURL URLByAppendingPathComponent:newStorageName].path;
+ const char *newStoragePathCstr =
+ [newStoragePath cStringUsingEncoding:NSUTF8StringEncoding];
+ FILE *newStorage = fopen(newStoragePathCstr, "a");
+ if (!newStorage) {
+ return nil;
+ }
+ fclose(newStorage);
+ return newStorageName;
+}
+
+- (NSString *)_getLockName:(NSString *)fileName {
+ return [NSString stringWithFormat:@"group.app.comm/%@", fileName];
+}
+
+- (NSString *)_getPath:(NSString *)fileName {
+ if (!fileName) {
+ return nil;
+ }
+ return [self.directoryURL URLByAppendingPathComponent:fileName].path;
+}
+
@end

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 2:48 AM (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2427785
Default Alt Text
D4472.id14469.diff (1 KB)

Event Timeline