provide incremental directories to mkdir

This commit is contained in:
4nshuman 2024-10-20 02:00:35 +05:30
parent 4fdea7db66
commit a646b02e45

View File

@ -152,12 +152,16 @@ const upload = async function(items, dirPath, options = {}){
// On the other hand if the file name is not blank(could be undefined), we need to create the file.
fileName != "" && files.push(entries[i])
if (options.createFileParent && fileItem.includes('/')) {
let filePath = path.join(dirPath, dirLevel)
// Prevent duplicate parent directory creation
if(!uniqueDirs[filePath]){
uniqueDirs[filePath] = true;
dirs.push({path: filePath});
}
let incrementalDir;
dirLevel.split('/').forEach((directory) => {
incrementalDir = incrementalDir ? incrementalDir + '/' + directory : directory;
let filePath = path.join(dirPath, incrementalDir)
// Prevent duplicate parent directory creation
if(!uniqueDirs[filePath]){
uniqueDirs[filePath] = true;
dirs.push({path: filePath});
}
})
}
}
// stats about the upload to come