Download empty_trash.php from Urban-Guy/Drive: direct link, hf CLI and curl.
- Browser
- Download file 920 Bytes
-
https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/empty_trash.php
- Command line
-
hf download hf://spaces/Urban-Guy/Drive/empty_trash.php
-
curl -L -o empty_trash.php https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/empty_trash.php
920 Bytes
| session_start(); | |
| $metadataFile = 'data/files.json'; | |
| function loadMetadata() { | |
| global $metadataFile; | |
| if (!file_exists($metadataFile)) return ['files' => []]; | |
| return json_decode(file_get_contents($metadataFile), true); | |
| } | |
| function saveMetadata($metadata) { | |
| global $metadataFile; | |
| file_put_contents($metadataFile, json_encode($metadata, JSON_PRETTY_PRINT)); | |
| } | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
| $metadata = loadMetadata(); | |
| $deletedCount = 0; | |
| foreach ($metadata['files'] as $key => $file) { | |
| if (isset($file['trashed']) && $file['trashed']) { | |
| if (file_exists($file['path'])) unlink($file['path']); | |
| unset($metadata['files'][$key]); | |
| $deletedCount++; | |
| } | |
| } | |
| $metadata['files'] = array_values($metadata['files']); | |
| saveMetadata($metadata); | |
| echo json_encode(['success' => true, 'deletedCount' => $deletedCount]); | |
| } | |