|
@@ -106,6 +106,9 @@ decl_error! {
|
|
|
|
|
|
/// Contant uploading failed. Actor quota objects limit exceeded.
|
|
|
GlobalQuotaObjectsLimitExceeded,
|
|
|
+
|
|
|
+ /// Content uploading blocked.
|
|
|
+ ContentUploadingBlocked,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -260,6 +263,9 @@ decl_storage! {
|
|
|
|
|
|
/// Global quota.
|
|
|
pub GlobalQuota get(fn global_quota) config(): Quota;
|
|
|
+
|
|
|
+ /// If all new uploads blocked
|
|
|
+ pub UploadingBlocked get(fn uploading_blocked) config(): bool;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -333,6 +339,8 @@ decl_module! {
|
|
|
ensure_root(origin)?;
|
|
|
};
|
|
|
|
|
|
+ Self::ensure_uploading_is_not_blocked()?;
|
|
|
+
|
|
|
Self::ensure_content_is_valid(&content)?;
|
|
|
|
|
|
let owner_quota = Self::get_quota(&owner);
|
|
@@ -499,6 +507,15 @@ impl<T: Trait> Module<T> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Ensure content uploading is not blocked
|
|
|
+ fn ensure_uploading_is_not_blocked() -> DispatchResult {
|
|
|
+ ensure!(
|
|
|
+ !Self::uploading_blocked(),
|
|
|
+ Error::<T>::ContentUploadingBlocked
|
|
|
+ );
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
+
|
|
|
// Ensure owner quota constraints satisfied, returns total object length and total size delta for this upload.
|
|
|
fn ensure_owner_quota_constraints_satisfied(
|
|
|
owner_quota: Quota,
|