MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / removeFile

Function removeFile

src/pages/fileBrowser/fileBrowser.js:1074–1117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1072 }
1073
1074 async function removeFile() {
1075 try {
1076 if (helpers.isDir(type)) {
1077 if (url.startsWith("content://com.termux.documents/tree/")) {
1078 const fs = fsOperation(url);
1079 const entries = await fs.lsDir();
1080 if (entries.length === 0) {
1081 await fs.delete();
1082 } else {
1083 const deleteRecursively = async (currentUrl) => {
1084 const currentFs = fsOperation(currentUrl);
1085 const currentEntries = await currentFs.lsDir();
1086 for (const entry of currentEntries) {
1087 if (entry.isDirectory) {
1088 await deleteRecursively(entry.url);
1089 } else {
1090 await fsOperation(entry.url).delete();
1091 }
1092 }
1093 await currentFs.delete();
1094 };
1095 await deleteRecursively(url);
1096 }
1097 } else {
1098 await fsOperation(url).delete();
1099 }
1100 helpers.updateUriOfAllActiveFiles(url);
1101 recents.removeFolder(url);
1102 } else {
1103 const fs = fsOperation(url);
1104 await fs.delete();
1105 const openedFile = editorManager.getFile(url, "uri");
1106 if (openedFile) openedFile.uri = null;
1107 }
1108 recents.removeFile(url);
1109 openFolder.removeItem(url);
1110 toast(strings.success);
1111 delete cachedDir[url];
1112 reload();
1113 } catch (err) {
1114 window.log("error", err);
1115 helpers.error(err);
1116 }
1117 }
1118
1119 function removeStorage() {
1120 if (url) {

Callers

nothing calls this directly

Calls 8

fsOperationFunction · 0.85
logMethod · 0.80
deleteRecursivelyFunction · 0.70
reloadFunction · 0.70
deleteMethod · 0.65
getFileMethod · 0.65
lsDirMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected