Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upload more than 100 files in directory #317

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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