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

Function removeChunkFolderRepeatedly

public/js/upload.js:876–911  ·  view source on GitHub ↗
(identifier, csrfToken, targetFolder = null, maxAttempts = 3, interval = 1000)

Source from the content-addressed store, hash-verified

874
875// Helper function to repeatedly call removeChunks.php
876function removeChunkFolderRepeatedly(identifier, csrfToken, targetFolder = null, maxAttempts = 3, interval = 1000) {
877 let attempt = 0;
878 const folder = (typeof targetFolder === "string" && targetFolder.trim() !== "")
879 ? targetFolder
880 : (window.currentFolder || "root");
881 const removalInterval = setInterval(() => {
882 attempt++;
883 const params = new URLSearchParams();
884 // Prefix with "resumable_" to match your PHP regex.
885 params.append('folder', 'resumable_' + identifier);
886 params.append('csrf_token', csrfToken);
887 params.append('targetFolder', folder);
888 const sourceId = getActiveUploadSourceId();
889 if (sourceId) {
890 params.append('sourceId', sourceId);
891 }
892 fetch(withBase('/api/upload/removeChunks.php'), {
893 method: 'POST',
894 credentials: 'include',
895 headers: {
896 'Content-Type': 'application/x-www-form-urlencoded'
897 },
898 body: params.toString()
899 })
900 .then(response => response.json())
901 .then(data => {
902 console.log(`Chunk folder removal attempt ${attempt}:`, data);
903 })
904 .catch(err => {
905 console.error(`Error on removal attempt ${attempt}:`, err);
906 });
907 if (attempt >= maxAttempts) {
908 clearInterval(removalInterval);
909 }
910 }, interval);
911}
912
913/* -----------------------------------------------------
914 File Entry Creation (with Pause/Resume and Restart)

Callers 2

showResumableDraftBannerFunction · 0.85
createFileEntryFunction · 0.85

Calls 3

getActiveUploadSourceIdFunction · 0.85
withBaseFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected