Skip to content

Commit a6c16c6

Browse files
max-zillalmarini
andauthored
Move file between folders reindex bugfix (#156)
* Reindex file & dataset on move * Update CHANGELOG.md Co-authored-by: Luigi Marini <[email protected]>
1 parent e8b5423 commit a6c16c6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## Unreleased
88

99
### Fixed
10+
- Files were not properly reindexed when the Move button was used to move a file into or out of a folder in a dataset.
11+
This has been fixed.
1012
- When adding a file to a dataset by URL, prioritize the URL `content-type` header over the file content type established
1113
by looking at the file name extension.
1214

app/api/Folders.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ class Folders @Inject() (
302302
if(oldFolder.files.contains(fileId)) {
303303
folders.removeFile(oldFolder.id, fileId)
304304
folders.addFile(newFolder.id, fileId)
305+
files.index(fileId)
306+
datasets.index(datasetId)
305307
Ok(toJson(Map("status" -> "success", "fileName" -> file.filename, "folderName" -> newFolder.name)))
306308
} else {
307309
BadRequest("Failed to move file. The file with id: " + file.id.stringify + " isn't in folder with id: " + oldFolder.id.stringify )
@@ -315,6 +317,8 @@ class Folders @Inject() (
315317
if(dataset.files.contains(fileId)) {
316318
folders.addFile(newFolder.id, fileId)
317319
datasets.removeFile(datasetId, fileId)
320+
files.index(fileId)
321+
datasets.index(datasetId)
318322
Ok(toJson(Map("status" -> "success", "fileName" -> file.filename, "folderName" -> newFolder.name)))
319323
} else {
320324
BadRequest("Failed to move file. The file with id: " + file.id.stringify + "Isn't in dataset with id: " + dataset.id.stringify )
@@ -353,6 +357,8 @@ class Folders @Inject() (
353357
if(folder.files.contains(fileId)) {
354358
datasets.addFile(datasetId, file)
355359
folders.removeFile(oldFolderId, fileId)
360+
files.index(fileId)
361+
datasets.index(datasetId)
356362
Ok(toJson(Map("status" -> "success", "fileName"-> file.filename )))
357363
} else {
358364
BadRequest("The file you are trying to move isn't in the folder you are moving it from.")

0 commit comments

Comments
 (0)