Skip to content

Commit

Permalink
fix: upload more than 100 files in directory (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
plantatorbob committed Dec 11, 2023
1 parent 8590f3e commit cd84dff
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ function ready() {

class Uploader {
/**
*
* @param {File} file
* @param {string[]} dirs
*
* @param {File} file
* @param {string[]} dirs
*/
constructor(file, dirs) {
/**
Expand Down Expand Up @@ -240,7 +240,7 @@ Uploader.runQueue = async () => {

/**
* Add breadcrumb
* @param {string} href
* @param {string} href
* @param {string} uri_prefix
*/
function addBreadcrumb(href, uri_prefix) {
Expand Down Expand Up @@ -365,8 +365,8 @@ function renderPathsTableBody() {

/**
* Add pathitem
* @param {PathItem} file
* @param {number} index
* @param {PathItem} file
* @param {number} index
*/
function addPath(file, index) {
const encodedName = encodedStr(file.name);
Expand Down Expand Up @@ -583,8 +583,8 @@ async function setupEditorPage() {

/**
* Delete path
* @param {number} index
* @returns
* @param {number} index
* @returns
*/
async function deletePath(index) {
const file = DATA.paths[index];
Expand Down Expand Up @@ -616,8 +616,8 @@ async function doDeletePath(name, url, cb) {

/**
* Move path
* @param {number} index
* @returns
* @param {number} index
* @returns
*/
async function movePath(index) {
const file = DATA.paths[index];
Expand Down Expand Up @@ -694,7 +694,7 @@ async function checkAuth() {

/**
* Create a folder
* @param {string} name
* @param {string} name
*/
async function createFolder(name) {
const url = newUrl(name);
Expand Down Expand Up @@ -732,8 +732,16 @@ async function addFileEntries(entries, dirs) {
new Uploader(file, dirs).upload();
});
} else if (entry.isDirectory) {
const dirReader = entry.createReader()
dirReader.readEntries(entries => addFileEntries(entries, [...dirs, entry.name]));
const dirReader = entry.createReader();

const successCallback = entries => {
if (entries.length > 0) {
addFileEntries(entries, [...dirs, entry.name]);
dirReader.readEntries(successCallback);
}
};

dirReader.readEntries(successCallback);
}
}
}
Expand Down

0 comments on commit cd84dff

Please sign in to comment.