Merge pull request #9658 from overleaf/em-dropbox-folder-sync
Sync folder creation from Dropbox to Overleaf GitOrigin-RevId: a2749ab8d9db7dd312818b46d6e72f1dbaaaff2e
This commit is contained in:
@@ -50,6 +50,7 @@ module.exports = {
|
||||
mkdirp: callbackifyMultiResult(wrapWithLock(mkdirp), [
|
||||
'newFolders',
|
||||
'folder',
|
||||
'parentFolder',
|
||||
]),
|
||||
moveEntity: callbackifyMultiResult(wrapWithLock(moveEntity), [
|
||||
'project',
|
||||
@@ -279,13 +280,14 @@ async function mkdirp(projectId, path, options = {}) {
|
||||
for (const folderName of folders) {
|
||||
builtUpPath += `/${folderName}`
|
||||
try {
|
||||
const { element: foundFolder } =
|
||||
const { element: foundFolder, folder: parentFolder } =
|
||||
await ProjectLocator.promises.findElementByPath({
|
||||
project,
|
||||
path: builtUpPath,
|
||||
exactCaseMatch: options.exactCaseMatch,
|
||||
})
|
||||
lastFolder = foundFolder
|
||||
lastFolder.parentFolder_id = parentFolder._id
|
||||
} catch (err) {
|
||||
// Folder couldn't be found. Create it.
|
||||
const parentFolderId = lastFolder && lastFolder._id
|
||||
|
||||
@@ -203,7 +203,7 @@ function _findElementByPathWithProject(
|
||||
function getEntity(folder, entityName, cb) {
|
||||
let result, type
|
||||
if (entityName == null) {
|
||||
return cb(null, folder, 'folder')
|
||||
return cb(null, folder, 'folder', null)
|
||||
}
|
||||
for (const file of iterablePaths(folder, 'fileRefs')) {
|
||||
if (matchFn(file != null ? file.name : undefined, entityName)) {
|
||||
@@ -227,7 +227,7 @@ function _findElementByPathWithProject(
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
cb(null, result, type)
|
||||
cb(null, result, type, folder)
|
||||
} else {
|
||||
cb(
|
||||
new Error(
|
||||
@@ -241,7 +241,7 @@ function _findElementByPathWithProject(
|
||||
return callback(new Error('Tried to find an element for a null project'))
|
||||
}
|
||||
if (needlePath === '' || needlePath === '/') {
|
||||
return callback(null, project.rootFolder[0], 'folder')
|
||||
return callback(null, project.rootFolder[0], 'folder', null)
|
||||
}
|
||||
|
||||
if (needlePath.indexOf('/') === 0) {
|
||||
@@ -317,6 +317,7 @@ module.exports = {
|
||||
findElementByPath: promisifyMultiResult(findElementByPath, [
|
||||
'element',
|
||||
'type',
|
||||
'folder',
|
||||
]),
|
||||
findRootDoc: promisifyMultiResult(findRootDoc, [
|
||||
'element',
|
||||
|
||||
Reference in New Issue
Block a user