Skip to content

Commit

Permalink
feat(Drive): Sample quota implementation for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Jan 27, 2025
1 parent 68d8ac8 commit d8a0615
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public extension Results where Element: KeypathSortable {
public final class DriveInfosManager: DriveInfosManagerQueryable {
private static let dbName = "DrivesInfos.realm"

private static let currentDbVersion: UInt64 = 11
private static let currentDbVersion: UInt64 = 12

let currentFpStorageVersion = 1

Expand Down
43 changes: 43 additions & 0 deletions kDriveCore/Data/Models/Drive/Drive+Quota.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2025 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import InfomaniakCore
import RealmSwift

public final class DriveQuota: EmbeddedObject, Codable {
@Persisted public var dropbox: Int?
@Persisted public var sharedLink: Int?

enum CodingKeys: String, CodingKey {
case dropbox
case sharedLink = "shared_link"
}
}

extension Drive {
var dropboxQuotaExceeded: Bool {
// TODO: Use real quota data
true
}

var sharedLinkQuotaExceeded: Bool {
// TODO: Use real quota data
true
}
}
3 changes: 3 additions & 0 deletions kDriveCore/Data/Models/Drive/Drive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public final class Drive: Object, Codable {
@Persisted public var maintenanceReason: MaintenanceReason?
@Persisted public var updatedAt: Date
@Persisted public var _account: DriveAccount?
@Persisted public var quota: DriveQuota?
/// Is manager admin.
@Persisted public var accountAdmin = false
/// Was product purchased with in-app purchase.
Expand Down Expand Up @@ -170,6 +171,7 @@ public final class Drive: Object, Codable {
_account = try values.decode(DriveAccount.self, forKey: ._account)
accountAdmin = try values.decode(Bool.self, forKey: .accountAdmin)
isInAppSubscription = try values.decode(Bool.self, forKey: .isInAppSubscription)
quota = try values.decodeIfPresent(DriveQuota.self, forKey: .isInAppSubscription)
}

override public init() {
Expand Down Expand Up @@ -214,6 +216,7 @@ public final class Drive: Object, Codable {
case _account = "account"
case accountAdmin
case isInAppSubscription
case quota
}

public static func == (lhs: Drive, rhs: Drive) -> Bool {
Expand Down

0 comments on commit d8a0615

Please sign in to comment.