(identifier, csrfToken, targetFolder = null, maxAttempts = 3, interval = 1000)
| 874 | |
| 875 | // Helper function to repeatedly call removeChunks.php |
| 876 | function 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) |
no test coverage detected