Merge pull request #9973 from overleaf/em-duplicate-filenames-conflict

Fix the automatic fixing of duplicate filenames

GitOrigin-RevId: 8ecdeb22c0c7f3c28983d4bf0f50c573193703b4
This commit is contained in:
Eric Mc Sween 2022-10-17 09:53:48 -04:00 committed by Copybot
parent 4af5ed24ad
commit 00b051e2d7

View file

@ -1522,6 +1522,26 @@ const ProjectEntityUpdateHandler = {
}
)
}
// Avoid conflicts by processing renames in the reverse order. If we have
// the following starting situation:
//
// somefile.tex
// somefile.tex
// somefile.tex (1)
//
// somefile.tex would be processed first, and then somefile.tex (1),
// yielding the following renames:
//
// somefile.tex -> somefile.tex (1)
// somefile.tex (1) -> somefile.tex (2)
//
// When the first rename was decided, we didn't know that somefile.tex (1)
// existed, so that created a conflict. By processing renames in the
// reverse order, we start with the files that had the most extensive
// information about existing files.
renames.reverse()
async.eachSeries(renames, doRename, callback)
},