refactor(drive): match DriveKind directly instead of Drive::is_personal()
Drops the boolean is_personal() wrapper in favor of matching DriveKind::Personal/Shared at the two call sites, matching the exhaustive-match convention already used for DriveKind elsewhere (as_str, parse, DriveKindDto::from).
This commit is contained in:
+9
-6
@@ -2169,12 +2169,15 @@ impl AppState {
|
||||
}
|
||||
|
||||
let drive = self.drive_repo.get_by_id(drive_id).await.ok()?.drive;
|
||||
if drive.is_personal() {
|
||||
let (used, quota) = storage_svc.get_user_storage_info(user_id).await.ok()?;
|
||||
Some((used, (quota > 0).then(|| (quota - used).max(0))))
|
||||
} else {
|
||||
let used = drive.used_bytes;
|
||||
Some((used, drive.quota_bytes.map(|q| (q - used).max(0))))
|
||||
match drive.kind {
|
||||
crate::domain::entities::drive::DriveKind::Personal => {
|
||||
let (used, quota) = storage_svc.get_user_storage_info(user_id).await.ok()?;
|
||||
Some((used, (quota > 0).then(|| (quota - used).max(0))))
|
||||
}
|
||||
crate::domain::entities::drive::DriveKind::Shared => {
|
||||
let used = drive.used_bytes;
|
||||
Some((used, drive.quota_bytes.map(|q| (q - used).max(0))))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user