Merge pull request #9647 from overleaf/bg-dropbox-to-overleaf-existing-doc

handle updates to existing doc in dropbox to overleaf metadata

GitOrigin-RevId: e82955a4a76e62fb649263a94103fdb7f322de85
This commit is contained in:
Eric Mc Sween
2022-09-22 08:04:11 +00:00
committed by Copybot
parent 76e0265ed7
commit 59cdcccc26
9 changed files with 77 additions and 51 deletions
@@ -238,23 +238,32 @@ module.exports = DocumentManager = {
// Otherwise we should remove it immediately since nothing else
// is using it.
if (alreadyLoaded) {
DocumentManager.flushDocIfLoaded(projectId, docId, error => {
if (error) {
return callback(error)
DocumentManager.flushDocIfLoaded(
projectId,
docId,
(error, result) => {
if (error) {
return callback(error)
}
callback(null, result)
}
callback(null)
})
)
} else {
DocumentManager.flushAndDeleteDoc(projectId, docId, {}, error => {
// There is no harm in flushing project history if the previous
// call failed and sometimes it is required
HistoryManager.flushProjectChangesAsync(projectId)
DocumentManager.flushAndDeleteDoc(
projectId,
docId,
{},
(error, result) => {
// There is no harm in flushing project history if the previous
// call failed and sometimes it is required
HistoryManager.flushProjectChangesAsync(projectId)
if (error) {
return callback(error)
if (error) {
return callback(error)
}
callback(null, result)
}
callback(null)
})
)
}
})
})
@@ -302,11 +311,16 @@ module.exports = DocumentManager = {
ranges,
lastUpdatedAt,
lastUpdatedBy,
error => {
(error, result) => {
if (error) {
return callback(error)
}
RedisManager.clearUnflushedTime(docId, callback)
RedisManager.clearUnflushedTime(docId, err => {
if (err) {
return callback(err)
}
callback(null, result)
})
}
)
}
@@ -321,7 +335,7 @@ module.exports = DocumentManager = {
_callback(...args)
}
DocumentManager.flushDocIfLoaded(projectId, docId, error => {
DocumentManager.flushDocIfLoaded(projectId, docId, (error, result) => {
if (error) {
if (options.ignoreFlushErrors) {
logger.warn(
@@ -340,7 +354,7 @@ module.exports = DocumentManager = {
if (error) {
return callback(error)
}
callback(null)
callback(null, result)
})
})
},