Skip to content

Commit b146b5b

Browse files
committed
fix
1 parent 1ce57e4 commit b146b5b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

app/api/Folders.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.collection.mutable.ListBuffer
2222
class Folders @Inject() (
2323
folders: FolderService,
2424
datasets: DatasetService,
25+
collections: CollectionService,
2526
files: FileService,
2627
events: EventService,
2728
routing: ExtractorRoutingService) extends ApiController {
@@ -316,6 +317,25 @@ class Folders @Inject() (
316317
if(dataset.files.contains(fileId)) {
317318
folders.addFile(newFolder.id, fileId)
318319
datasets.removeFile(datasetId, fileId)
320+
321+
// when moving a file in the root of a dataset inside a folder
322+
// check if that file has been used as thumbnail
323+
// if yes, update the thumbnail of both dataset and collection
324+
if(!file.thumbnail_id.isEmpty && !dataset.thumbnail_id.isEmpty){
325+
if (file.thumbnail_id.get.equals(dataset.thumbnail_id.get)){
326+
datasets.newThumbnail(dataset.id)
327+
collections.get(dataset.collections).found.foreach(collection => {
328+
if(!collection.thumbnail_id.isEmpty){
329+
if(collection.thumbnail_id.get.equals(dataset.thumbnail_id.get)){
330+
collections.createThumbnail(collection.id)
331+
}
332+
}
333+
})
334+
}
335+
}
336+
}
337+
}
338+
319339
files.index(fileId)
320340
datasets.index(datasetId)
321341
Ok(toJson(Map("status" -> "success", "fileName" -> file.filename, "folderName" -> newFolder.name)))

0 commit comments

Comments
 (0)