Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview replace fileNamePath with fileId #2952

Closed
wants to merge 1 commit into from
Closed
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 @@ -5620,8 +5620,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
requirement = {
kind = exactVersion;
version = 3.0.1;
branch = "preview-fileId";
kind = branch;
};
};
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
Expand Down
3 changes: 1 addition & 2 deletions Widget/Files/FilesData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,10 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
if let result = utility.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) {
image = result
} else if file.hasPreview {
let fileNamePathOrFileId = utilityFileSystem.getFileNamePath(file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, userId: file.userId)
let fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)
let fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)
let sizePreview = NCUtility().getSizePreview(width: Int(file.width), height: Int(file.height))
let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: options)
let (_, _, imageIcon, _, _, _) = await NextcloudKit.shared.downloadPreview(fileId: file.fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: Int(sizePreview.width), heightPreview: Int(sizePreview.height), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, options: options)
if let result = imageIcon {
image = result
}
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Activity/NCActivityTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class NCOperationDownloadThumbnailActivity: ConcurrentOperation {

guard !isCancelled else { return self.finish() }

NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId,
NextcloudKit.shared.downloadPreview(fileId: fileNamePathOrFileId,
fileNamePreviewLocalPath: fileNamePreviewLocalPath,
widthPreview: 0,
heightPreview: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation {
var metadata: tableMetadata
var cell: NCCellProtocol?
var collectionView: UICollectionView?
var fileNamePath: String
var fileNamePreviewLocalPath: String
var fileNameIconLocalPath: String
let utilityFileSystem = NCUtilityFileSystem()
Expand All @@ -40,7 +39,6 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation {
self.metadata = tableMetadata.init(value: metadata)
self.cell = cell
self.collectionView = collectionView
self.fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
self.fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)
self.fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
}
Expand All @@ -55,7 +53,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation {
etagResource = metadata.etagResource
}

NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath,
NextcloudKit.shared.downloadPreview(fileId: metadata.fileId,
fileNamePreviewLocalPath: fileNamePreviewLocalPath,
widthPreview: Int(sizePreview.width),
heightPreview: Int(sizePreview.height),
Expand Down
4 changes: 1 addition & 3 deletions iOSClient/Media/NCMediaDownloadThumbnaill.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation {

var metadata: tableMetadata
var media: NCMedia
var fileNamePath: String
var fileNamePreviewLocalPath: String
var fileNameIconLocalPath: String
let utilityFileSystem = NCUtilityFileSystem()

init(metadata: tableMetadata, media: NCMedia) {
self.metadata = tableMetadata.init(value: metadata)
self.media = media
self.fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
self.fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)
self.fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
}
Expand All @@ -52,7 +50,7 @@ class NCMediaDownloadThumbnaill: ConcurrentOperation {
etagResource = metadata.etagResource
}

NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath,
NextcloudKit.shared.downloadPreview(fileId: metadata.fileId,
fileNamePreviewLocalPath: fileNamePreviewLocalPath,
widthPreview: Int(sizePreview.width),
heightPreview: Int(sizePreview.height),
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Networking/NCNetworking+WebDAV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ extension NCNetworking {

// MARK: - Download Preview

func downloadPreview(fileNamePathOrFileId: String,
func downloadPreview(fileId: String,
fileNamePreviewLocalPath: String,
widthPreview: Int,
heightPreview: Int,
Expand All @@ -707,7 +707,7 @@ extension NCNetworking {
options: NKRequestOptions = NKRequestOptions()) async -> (account: String, imagePreview: UIImage?, imageIcon: UIImage?, imageOriginal: UIImage?, etag: String?, error: NKError) {

await withUnsafeContinuation({ continuation in
NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: widthPreview, heightPreview: heightPreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: sizeIcon, etag: etag, options: options) { account, imagePreview, imageIcon, imageOriginal, etag, error in
NextcloudKit.shared.downloadPreview(fileId: fileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: widthPreview, heightPreview: heightPreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: sizeIcon, etag: etag, options: options) { account, imagePreview, imageIcon, imageOriginal, etag, error in
continuation.resume(returning: (account: account, imagePreview: imagePreview, imageIcon: imageIcon, imageOriginal: imageOriginal, etag: etag, error: error))
}
})
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Trash/NCTrash+Networking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class NCOperationDownloadThumbnailTrash: ConcurrentOperation {
let fileNamePreviewLocalPath = NCUtilityFileSystem().getDirectoryProviderStoragePreviewOcId(tableTrash.fileId, etag: tableTrash.fileName)
let fileNameIconLocalPath = NCUtilityFileSystem().getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)

NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: tableTrash.fileId,
NextcloudKit.shared.downloadPreview(fileId: tableTrash.fileId,
fileNamePreviewLocalPath: fileNamePreviewLocalPath,
widthPreview: NCGlobal.shared.sizePreview,
heightPreview: NCGlobal.shared.sizePreview,
Expand Down
3 changes: 1 addition & 2 deletions iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,11 @@ class NCViewerMedia: UIViewController {
if utilityFileSystem.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
return completion(UIImage(contentsOfFile: utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)))
} else {
let fileNamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId)
let fileNamePreviewLocalPath = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)
let fileNameIconLocalPath = utilityFileSystem.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)
let sizePreview = NCUtility().getSizePreview(width: metadata.width, height: metadata.height)

NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePath,
NextcloudKit.shared.downloadPreview(fileId: metadata.fileId,
fileNamePreviewLocalPath: fileNamePreviewLocalPath,
widthPreview: Int(sizePreview.width),
heightPreview: Int(sizePreview.height),
Expand Down
Loading