Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6323,7 +6323,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
Expand Down Expand Up @@ -6391,7 +6391,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = NKUJUXUJ3B;
Expand Down
33 changes: 16 additions & 17 deletions iOSClient/Utility/NCUtilityFileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ final class NCUtilityFileSystem: NSObject, @unchecked Sendable {
let minimumDate = Date().addingTimeInterval(-days * 24 * 60 * 60)
let storageURL = URL(fileURLWithPath: getDirectoryProviderStorage())
let manager = FileManager.default

var offlineDirectories: [String] = []
var protectedOcIds = Set<String>()

let directories = await database.getTablesDirectoryAsync(
predicate: NSPredicate(format: "offline == true"),
Expand All @@ -811,17 +810,20 @@ final class NCUtilityFileSystem: NSObject, @unchecked Sendable {
)

for directory in directories {
guard let metadata = await database.getMetadataFromOcIdAsync(directory.ocId) else {
continue
}

let path = getDirectoryProviderStorageOcId(
metadata.ocId,
userId: metadata.userId,
urlBase: metadata.urlBase
let serverUrl = directory.serverUrl.hasSuffix("/")
? String(directory.serverUrl.dropLast())
: directory.serverUrl
let metadatas: [tableMetadata] = await database.getMetadatasAsync(
predicate: NSPredicate(
format: "account == %@ AND directory == false AND (serverUrl == %@ OR serverUrl BEGINSWITH %@)",
directory.account,
serverUrl,
serverUrl + "/"
)
)

offlineDirectories.append(path)
protectedOcIds.insert(directory.ocId)
protectedOcIds.formUnion(metadatas.map(\.ocId))
}

let localFiles = await database.getTableLocalFilesAsync(
Expand All @@ -847,10 +849,10 @@ final class NCUtilityFileSystem: NSObject, @unchecked Sendable {
((attributes[.size] as? NSNumber)?.uint64Value ?? 0) > 0 else {
continue
}
let directoryURL = fileURL.deletingLastPathComponent()
let ocId = directoryURL.lastPathComponent

if offlineDirectories.contains(where: {
fileURL.path == $0 || fileURL.path.hasPrefix($0 + "/")
}) {
if protectedOcIds.contains(ocId) {
continue
}

Expand All @@ -866,9 +868,6 @@ final class NCUtilityFileSystem: NSObject, @unchecked Sendable {
}
}

let directoryURL = fileURL.deletingLastPathComponent()
let ocId = directoryURL.lastPathComponent

guard !processedOcIds.contains(ocId),
let localFile = localFilesByOcId[ocId],
(localFile.lastOpeningDate as Date) < minimumDate else {
Expand Down
Loading