Skip to content

Commit

Permalink
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
Browse files Browse the repository at this point in the history
…alLinks-addToMyDriveCellAction
  • Loading branch information
adrien-coye committed Jan 2, 2025
2 parents 26b1097 + 6deacca commit b9eb981
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ let project = Project(name: "kDrive",
.external(name: "CocoaLumberjackSwift"),
.external(name: "MaterialOutlinedTextField"),
.external(name: "SwiftRegex"),
.external(name: "Sentry"),
.external(name: "Sentry-Dynamic"),
.external(name: "VersionChecker"),
.external(name: "LocalizeKit")
]),
Expand Down
40 changes: 20 additions & 20 deletions Tuist/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire",
"state" : {
"revision" : "e16d3481f5ed35f0472cb93350085853d754913f",
"version" : "5.10.1"
"revision" : "513364f870f6bfc468f9d2ff0a95caccc10044c5",
"version" : "5.10.2"
}
},
{
"identity" : "atlantis",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ProxymanApp/atlantis",
"state" : {
"revision" : "b60fb9920e50f8f8a7e909394b09989c9d55d7ef",
"version" : "1.25.2"
"revision" : "7246950a6a36454ed1d7830166284f202dc14ad2",
"version" : "1.26.0"
}
},
{
Expand Down Expand Up @@ -86,17 +86,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-core",
"state" : {
"revision" : "e0eca0781740231a95c0f32dc0ae5e2f92867a4e",
"version" : "12.8.0"
"revision" : "eaf53f35780befa26d2ac30c8262d7529352bfb9",
"version" : "13.0.0"
}
},
{
"identity" : "ios-core-ui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-core-ui",
"state" : {
"revision" : "e0afbab522df72496b92042ee65c20f8d593a3f7",
"version" : "13.4.0"
"revision" : "ab6c8412f09af1dd55b62c0d888cb6fb3984fb18",
"version" : "16.0.0"
}
},
{
Expand All @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-version-checker",
"state" : {
"revision" : "5b68ced5b52f9c95b6cb6d671273c608ed38d2fc",
"version" : "7.0.2"
"revision" : "7027616a4fc3d5b1464f55c934111724356ebac3",
"version" : "8.0.0"
}
},
{
Expand Down Expand Up @@ -221,17 +221,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-swift",
"state" : {
"revision" : "5553cfd1c789efdb3d6daf7f0cc0733cfe601846",
"version" : "10.54.1"
"revision" : "a3abcdf95a3176f5ad990239920aad4ef86e00de",
"version" : "10.54.2"
}
},
{
"identity" : "sentry-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa",
"state" : {
"revision" : "0ffc3c6287461962cb2a81e57fc0ee0335d8d56a",
"version" : "8.40.1"
"revision" : "c1404acfa3a71e42aa789c6d5564da59d4377569",
"version" : "8.42.1"
}
},
{
Expand Down Expand Up @@ -284,26 +284,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/swift-concurrency",
"state" : {
"revision" : "55fe7541cbfcfb4b73e7836b390e2c566a9ba910",
"version" : "0.0.6"
"revision" : "97ae7c9b998a43812d3f57ae106cb447a853bf3b",
"version" : "1.0.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
"version" : "1.6.2"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "914081701062b11e3bb9e21accc379822621995e",
"version" : "2.76.1"
"revision" : "dca6594f65308c761a9c409e09fbf35f48d50d34",
"version" : "2.77.0"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-algorithms", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/Alamofire/Alamofire", .upToNextMajor(from: "5.2.2")),
.package(url: "https://github.com/Infomaniak/ios-core", .upToNextMajor(from: "12.8.0")),
.package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "13.1.0")),
.package(url: "https://github.com/Infomaniak/ios-core", .upToNextMajor(from: "13.0.0")),
.package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "16.0.0")),
.package(url: "https://github.com/Infomaniak/ios-login", .upToNextMajor(from: "7.0.1")),
.package(url: "https://github.com/Infomaniak/ios-dependency-injection", .upToNextMajor(from: "2.0.0")),
.package(url: "https://github.com/Infomaniak/swift-concurrency", .upToNextMajor(from: "0.0.4")),
.package(url: "https://github.com/Infomaniak/ios-version-checker", .upToNextMajor(from: "7.0.0")),
.package(url: "https://github.com/Infomaniak/swift-concurrency", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/Infomaniak/ios-version-checker", .upToNextMajor(from: "8.0.0")),
.package(url: "https://github.com/Infomaniak/LocalizeKit", .upToNextMajor(from: "1.0.2")),
.package(url: "https://github.com/realm/realm-swift", .upToNextMajor(from: "10.52.0")),
.package(url: "https://github.com/SCENEE/FloatingPanel", .upToNextMajor(from: "2.0.0")),
Expand Down
2 changes: 1 addition & 1 deletion Tuist/ProjectDescriptionHelpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public enum Constants {
public static let baseSettings = SettingsDictionary()
.automaticCodeSigning(devTeam: "864VDCS2QY")
.currentProjectVersion("1")
.marketingVersion("5.0.2")
.marketingVersion("5.0.3")

public static let deploymentTarget = DeploymentTargets.iOS("13.4")
public static let destinations = Set<Destination>([.iPhone, .iPad])
Expand Down
7 changes: 6 additions & 1 deletion kDrive/UI/Controller/Menu/Trash/TrashListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class TrashListViewModel: InMemoryFileListViewModel {
endRefreshing()

if currentDirectory.id == DriveFileManager.trashRootFile.id {
currentRightBarButtons = files.isEmpty ? nil : [.emptyTrash]
currentRightBarButtons = currentDirectory.children.isEmpty ? nil : [.emptyTrash]
}

if let nextCursor = fetchResponse.validApiResponse.cursor {
try await loadFiles(cursor: nextCursor)
}
Expand Down Expand Up @@ -150,6 +151,10 @@ class TrashListViewModel: InMemoryFileListViewModel {
sortingChanged()
}

override func shouldShowEmptyView() -> Bool {
currentDirectory.children.isEmpty
}

private func restoreTrashedFiles(
_ restoredFiles: [ProxyFile],
firstFilename: String,
Expand Down
1 change: 1 addition & 0 deletions kDriveCore/AudioPlayer/SingleTrackPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public final class SingleTrackPlayer: Pausable {
/// Async as may take up some time
public func setup(with playableFile: File) async { // TODO: use abstract type
if !playableFile.isLocalVersionOlderThanRemote {
removeAllObservers()
let asset = AVAsset(url: playableFile.localUrl)
player = AVPlayer(url: playableFile.localUrl)
setUpObservers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ public class DownloadOperation: Operation, DownloadOperationable {
// MARK: - Attributes

private let fileManager = FileManager.default
private let driveFileManager: DriveFileManager
private let urlSession: FileDownloadSession
private let publicShareProxy: PublicShareProxy?
private let itemIdentifier: NSFileProviderItemIdentifier?
private var progressObservation: NSKeyValueObservation?
private var backgroundTaskIdentifier: UIBackgroundTaskIdentifier = .invalid

@LazyInjectService(customTypeIdentifier: kDriveDBID.uploads) private var uploadsDatabase: Transactionable

@LazyInjectService(customTypeIdentifier: kDriveDBID.uploads) var uploadsDatabase: Transactionable
@LazyInjectService var accountManager: AccountManageable
@LazyInjectService var driveInfosManager: DriveInfosManager
@LazyInjectService var downloadManager: BackgroundDownloadSessionManager
@LazyInjectService var appContextService: AppContextServiceable

let urlSession: FileDownloadSession
let driveFileManager: DriveFileManager
var progressObservation: NSKeyValueObservation?

public let file: File
public var task: URLSessionDownloadTask?
public var error: DriveError?
Expand Down Expand Up @@ -94,13 +93,11 @@ public class DownloadOperation: Operation, DownloadOperationable {
file: File,
driveFileManager: DriveFileManager,
urlSession: FileDownloadSession,
publicShareProxy: PublicShareProxy? = nil,
itemIdentifier: NSFileProviderItemIdentifier? = nil
) {
self.file = File(value: file)
self.driveFileManager = driveFileManager
self.urlSession = urlSession
self.publicShareProxy = publicShareProxy
self.itemIdentifier = itemIdentifier
}

Expand All @@ -112,7 +109,6 @@ public class DownloadOperation: Operation, DownloadOperationable {
self.driveFileManager = driveFileManager
self.urlSession = urlSession
self.task = task
publicShareProxy = nil
itemIdentifier = nil
}

Expand Down Expand Up @@ -179,17 +175,13 @@ public class DownloadOperation: Operation, DownloadOperationable {
override public func main() {
DDLogInfo("[DownloadOperation] Start for \(file.id) with session \(urlSession.identifier)")

if let publicShareProxy {
downloadPublicShareFile(publicShareProxy: publicShareProxy)
} else {
downloadFile()
}
downloadFile()
}

private func downloadPublicShareFile(publicShareProxy: PublicShareProxy) {
DDLogInfo("[DownloadOperation] Downloading publicShare \(file.id) with session \(urlSession.identifier)")
private func downloadFile() {
DDLogInfo("[DownloadOperation] Downloading \(file.id) with session \(urlSession.identifier)")

let url = Endpoint.download(file: file, publicShareProxy: publicShareProxy).url
let url = Endpoint.download(file: file).url

// Add download task to Realm
let downloadTask = DownloadTask(
Expand All @@ -205,7 +197,17 @@ public class DownloadOperation: Operation, DownloadOperationable {
writableRealm.add(downloadTask, update: .modified)
}

let request = URLRequest(url: url)
if let token = getToken() {
var request = URLRequest(url: url)
request.setValue("Bearer \(token.accessToken)", forHTTPHeaderField: "Authorization")
downloadRequest(request)
} else {
error = .unknownToken // Other error?
end(sessionUrl: url)
}
}

func downloadRequest(_ request: URLRequest) {
task = urlSession.downloadTask(with: request, completionHandler: downloadCompletion)
progressObservation = task?.progress.observe(\.fractionCompleted, options: .new) { [fileId = file.id] _, value in
guard let newValue = value.newValue else {
Expand All @@ -223,49 +225,6 @@ public class DownloadOperation: Operation, DownloadOperationable {
task?.resume()
}

private func downloadFile() {
DDLogInfo("[DownloadOperation] Downloading \(file.id) with session \(urlSession.identifier)")

let url = Endpoint.download(file: file).url

// Add download task to Realm
let downloadTask = DownloadTask(
fileId: file.id,
isDirectory: file.isDirectory,
driveId: file.driveId,
userId: driveFileManager.drive.userId,
sessionId: urlSession.identifier,
sessionUrl: url.absoluteString
)

try? uploadsDatabase.writeTransaction { writableRealm in
writableRealm.add(downloadTask, update: .modified)
}

if let token = getToken() {
var request = URLRequest(url: url)
request.setValue("Bearer \(token.accessToken)", forHTTPHeaderField: "Authorization")
task = urlSession.downloadTask(with: request, completionHandler: downloadCompletion)
progressObservation = task?.progress.observe(\.fractionCompleted, options: .new) { [fileId = file.id] _, value in
guard let newValue = value.newValue else {
return
}
DownloadQueue.instance.publishProgress(newValue, for: fileId)
}
if let itemIdentifier {
driveInfosManager.getFileProviderManager(for: driveFileManager.drive) { manager in
manager.register(self.task!, forItemWithIdentifier: itemIdentifier) { _ in
// META: keep SonarCloud happy
}
}
}
task?.resume()
} else {
error = .unknownToken // Other error?
end(sessionUrl: url)
}
}

override public func cancel() {
DDLogInfo("[DownloadOperation] Download of \(file.id) canceled")
super.cancel()
Expand Down Expand Up @@ -342,7 +301,10 @@ public class DownloadOperation: Operation, DownloadOperationable {
return
}

assert(file.isDownloaded, "Expecting to be downloaded at the end of the downloadOperation error:\(error)")
assert(
file.isDownloaded,
"Expecting to be downloaded at the end of the downloadOperation error:\(String(describing: error))"
)

try? uploadsDatabase.writeTransaction { writableRealm in
guard let task = writableRealm.objects(DownloadTask.self)
Expand Down
Loading

0 comments on commit b9eb981

Please sign in to comment.