Преглед изворни кода

Merge pull request #10888 from overleaf/bg-case-sensitive-delete

Make dropbox deletes case-sensitive

GitOrigin-RevId: 090112ce82e38f15079053952db4b0a1544e8300
Brian Gough пре 3 година
родитељ
комит
2cc2da18a5

+ 1 - 1
services/web/app/src/Features/Project/ProjectEntityUpdateHandler.js

@@ -1163,7 +1163,7 @@ const ProjectEntityUpdateHandler = {
   deleteEntityWithPath: wrapWithLock(
     (projectId, path, userId, source, callback) =>
       ProjectLocator.findElementByPath(
-        { project_id: projectId, path },
+        { project_id: projectId, path, exactCaseMatch: true },
         (err, element, type) => {
           if (err != null) {
             return callback(err)

+ 5 - 1
services/web/test/unit/src/Project/ProjectEntityUpdateHandlerTests.js

@@ -1632,7 +1632,11 @@ describe('ProjectEntityUpdateHandler', function () {
 
       it('finds the entity', function () {
         this.ProjectLocator.findElementByPath
-          .calledWith({ project_id: projectId, path: this.path })
+          .calledWith({
+            project_id: projectId,
+            path: this.path,
+            exactCaseMatch: true,
+          })
           .should.equal(true)
       })
 

+ 13 - 0
services/web/test/unit/src/Project/ProjectLocatorTests.js

@@ -400,6 +400,19 @@ describe('ProjectLocator', function () {
       )
     })
 
+    it('should not return elements with a case-insensitive match when exactCaseMatch is true', function (done) {
+      const path = `${subFolder.name.toUpperCase()}/${secondSubFolder.name.toUpperCase()}/${subSubFile.name.toUpperCase()}`
+      this.locator.findElementByPath(
+        { project, path, exactCaseMatch: true },
+        (err, element, type, folder) => {
+          err.should.not.equal(undefined)
+          expect(element).to.be.undefined
+          expect(type).to.be.undefined
+          done()
+        }
+      )
+    })
+
     it('should take a file path and return the element for a nested folder', function (done) {
       const path = `${subFolder.name}/${secondSubFolder.name}`
       this.locator.findElementByPath(