MCPcopy Create free account
hub / github.com/error311/FileRise / deleteSubtree

Method deleteSubtree

src/FileRise/Support/MetadataPath.php:58–82  ·  view source on GitHub ↗
(string $metaRoot, string $folder)

Source from the content-addressed store, hash-verified

56 }
57
58 public static function deleteSubtree(string $metaRoot, string $folder): void
59 {
60 $metaRoot = rtrim($metaRoot, '/\\') . DIRECTORY_SEPARATOR;
61 $folder = self::folderKey($folder);
62 if ($folder === 'root') {
63 return;
64 }
65
66 foreach (self::newSubtreeGlobPatterns($metaRoot, $folder) as $pattern) {
67 foreach (glob($pattern) ?: [] as $path) {
68 if (is_file($path)) {
69 @unlink($path);
70 }
71 }
72 }
73
74 if (!self::isCollisionSensitive($folder)) {
75 $legacyPrefix = str_replace(['/', '\\', ' '], '-', $folder);
76 foreach (glob($metaRoot . $legacyPrefix . '*_metadata.json') ?: [] as $path) {
77 if (is_file($path)) {
78 @unlink($path);
79 }
80 }
81 }
82 }
83
84 public static function renameSubtree(string $metaRoot, string $oldFolder, string $newFolder): void
85 {

Calls 3

folderKeyMethod · 0.95
isCollisionSensitiveMethod · 0.95

Tested by

no test coverage detected