@@ -22,6 +22,7 @@ import scala.collection.mutable.ListBuffer
2222class 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,23 @@ 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+
319337 files.index(fileId)
320338 datasets.index(datasetId)
321339 Ok (toJson(Map (" status" -> " success" , " fileName" -> file.filename, " folderName" -> newFolder.name)))
0 commit comments