Merge branch 'mkirk/attachment-download-failures' into release/2.30.2
This commit is contained in:
commit
049fd63f48
@ -214,8 +214,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
|
||||
// a single launch of the app. Since our "date threshold"
|
||||
// for deletion is relative to the current launch time,
|
||||
// all temp files currently in use should be safe.
|
||||
NSString *temporaryDirectory = NSTemporaryDirectory();
|
||||
NSArray<NSString *> *_Nullable tempFilePaths = [self filePathsInDirectorySafe:temporaryDirectory].allObjects;
|
||||
NSArray<NSString *> *_Nullable tempFilePaths = [self getTempFilePaths];
|
||||
if (!tempFilePaths || !self.isMainAppAndActive) {
|
||||
return nil;
|
||||
}
|
||||
@ -714,6 +713,21 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (nullable NSArray<NSString *> *)getTempFilePaths
|
||||
{
|
||||
NSString *dir1 = NSTemporaryDirectory();
|
||||
NSArray<NSString *> *_Nullable paths1 = [[self filePathsInDirectorySafe:dir1].allObjects mutableCopy];
|
||||
|
||||
NSString *dir2 = OWSFileSystem.accessibleAfterFirstAuthTempDirectoryPath;
|
||||
NSArray<NSString *> *_Nullable paths2 = [[self filePathsInDirectorySafe:dir2].allObjects mutableCopy];
|
||||
|
||||
if (paths1 && paths2) {
|
||||
return [paths1 arrayByAddingObjectsFromArray:paths2];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -312,7 +312,8 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f;
|
||||
const long kMaxDownloadSize = 150 * 1024 * 1024;
|
||||
__block BOOL hasCheckedContentLength = NO;
|
||||
|
||||
NSString *tempSubdirPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
|
||||
NSString *tempSubdirPath = [OWSFileSystem.accessibleAfterFirstAuthTempDirectoryPath
|
||||
stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
|
||||
NSString *tempFilePath1 = [tempSubdirPath stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
|
||||
NSString *tempFilePath2 = [tempSubdirPath stringByAppendingPathComponent:[NSUUID UUID].UUIDString];
|
||||
NSURL *tempFileURL1 = [NSURL fileURLWithPath:tempFilePath1];
|
||||
|
||||
@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (NSString *)appSharedDataDirectoryPath;
|
||||
|
||||
+ (NSString *)accessibleAfterFirstAuthTempDirectoryPath;
|
||||
|
||||
+ (NSString *)cachesDirectoryPath;
|
||||
|
||||
+ (nullable NSError *)renameFilePathUsingRandomExtension:(NSString *)oldFilePath;
|
||||
|
||||
@ -110,6 +110,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
return CurrentAppContext().appSharedDataDirectoryPath;
|
||||
}
|
||||
|
||||
+ (NSString *)accessibleAfterFirstAuthTempDirectoryPath
|
||||
{
|
||||
NSString *const dirName = @"accessibleAfterFirstAuthTmp";
|
||||
NSString *const dirPath = [[self appDocumentDirectoryPath] stringByAppendingPathComponent:dirName];
|
||||
BOOL ok = [self ensureDirectoryExists:dirPath];
|
||||
OWSAssert(ok);
|
||||
return dirPath;
|
||||
}
|
||||
|
||||
+ (NSString *)cachesDirectoryPath
|
||||
{
|
||||
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user