-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathItem+Ignored.swift
More file actions
77 lines (70 loc) · 2.66 KB
/
Item+Ignored.swift
File metadata and controls
77 lines (70 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: LGPL-3.0-or-later
@preconcurrency import FileProvider
import NextcloudKit
extension Item {
static func createIgnored(
basedOn itemTemplate: NSFileProviderItem,
parentItemRemotePath: String,
contents _: URL?,
account: Account,
remoteInterface: RemoteInterface,
progress _: Progress,
dbManager: FilesDatabaseManager,
log: any FileProviderLogging
) async -> (Item?, Error?) {
let filename = itemTemplate.filename
let logger = FileProviderLogger(category: "Item", log: log)
logger.info(
"""
File \(filename) is in the ignore list.
\(parentItemRemotePath + "/" + filename)
Will not propagate creation to server.
"""
)
let metadata = SendableItemMetadata(
ocId: itemTemplate.itemIdentifier.rawValue,
account: account.ncKitAccount,
classFile: NKTypeClassFile.unknow.rawValue,
contentType: itemTemplate.contentType?.preferredMIMEType ?? "",
creationDate: itemTemplate.creationDate as? Date ?? Date(),
date: itemTemplate.contentModificationDate as? Date ?? Date(),
directory: itemTemplate.contentType?.conforms(to: .directory) ?? false,
e2eEncrypted: false,
etag: "",
fileId: itemTemplate.itemIdentifier.rawValue,
fileName: itemTemplate.filename,
fileNameView: itemTemplate.filename,
hasPreview: false,
iconName: "",
mountType: "",
ownerId: account.id,
ownerDisplayName: "",
path: "",
serverUrl: parentItemRemotePath,
size: itemTemplate.documentSize??.int64Value ?? 0,
status: Status.normal.rawValue,
downloaded: true,
uploaded: false,
urlBase: account.serverUrl,
user: account.username,
userId: account.id,
wasTrashedLocally: false
)
dbManager.addItemMetadata(metadata)
let item = await Item(
metadata: metadata,
parentItemIdentifier: itemTemplate.parentItemIdentifier,
account: account,
remoteInterface: remoteInterface,
dbManager: dbManager,
remoteSupportsTrash: remoteInterface.supportsTrash(account: account),
log: log
)
if #available(macOS 13.0, *) {
return (item, NSFileProviderError(.excludedFromSync))
} else {
return (item, nil)
}
}
}