Page MenuHomePhabricator

D4472.id14704.diff
No OneTemporary

D4472.id14704.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
Fri, Dec 27, 3:48 PM (2 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2716061
Default Alt Text
D4472.id14704.diff (1 KB)

Event Timeline