Page MenuHomePhabricator

D4472.id14638.diff
No OneTemporary

D4472.id14638.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:43 AM (20 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2427785
Default Alt Text
D4472.id14638.diff (1 KB)

Event Timeline