MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / admin_delete_user

Function admin_delete_user

Scripts/ButSystem.py:12245–12287  ·  view source on GitHub ↗

admin_delete_user. Admin-only route handler. This docstring was expanded to make future maintenance easier. Returns: Varies.

()

Source from the content-addressed store, hash-verified

12243
12244
12245def _disk_allows_upload(target_dir: str, expected_total: int, already_written: int = 0) -> bool:
12246 try:
12247 usage = shutil.disk_usage(target_dir)
12248 remaining = max(0, int(expected_total) - max(0, int(already_written)))
12249 predicted = int(usage.used) + remaining
12250 return usage.total > 0 and (predicted / usage.total) < FILE_STORAGE_MAX_RATIO and usage.free >= remaining
12251 except Exception:
12252 return False
12253
12254
12255def _storage_stats(username: str) -> Dict[str, Any]:
12256 root = user_root(username)
12257 usage = shutil.disk_usage(root)
12258 percent = round((usage.used / usage.total) * 100, 1) if usage.total else 0
12259 return {"total": usage.total, "used": usage.used, "free": usage.free, "total_h": human_size(usage.total), "used_h": human_size(usage.used), "free_h": human_size(usage.free), "percent": percent}
12260
12261
12262def _folder_size(path: str) -> int:
12263 total = 0
12264 for root, dirs, files_ in os.walk(path, followlinks=False):
12265 dirs[:] = [d for d in dirs if not os.path.islink(os.path.join(root, d))]
12266 for name in files_:
12267 fp = os.path.join(root, name)
12268 try:
12269 if not os.path.islink(fp):
12270 total += os.path.getsize(fp)
12271 except Exception:
12272 pass
12273 return total
12274
12275
12276def _sha256_file(path: str) -> str:
12277 digest = hashlib.sha256()
12278 with open(path, "rb") as fh:
12279 while True:
12280 block = fh.read(8 * 1024 * 1024)
12281 if not block:
12282 break
12283 digest.update(block)
12284 return digest.hexdigest()
12285
12286
12287def _all_user_folders(username: str, exclude_rel: str = "") -> List[str]:
12288 root = user_root(username)
12289 exclude_rel = safe_relpath(exclude_rel)
12290 output = []

Callers

nothing calls this directly

Calls 5

require_adminFunction · 0.70
current_userFunction · 0.70
db_connectFunction · 0.70
user_is_adminFunction · 0.70
user_rootFunction · 0.70

Tested by

no test coverage detected