diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c71a6a8e..d911f2f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). for passing in credentials to the S3ByteStorageService. ### Fixed +- Upgraded extractor parameters jsonform to version `2.2.5`. - Cleaning up after a failed upload should no longer decrement the file + byte counts. +- Fix the broken link after file deletion within a folder. [#277](https://github.com/clowder-framework/clowder/issues/277) ### Changed - now building mongo-init and monitor docker containers with python 3.8 diff --git a/app/api/Folders.scala b/app/api/Folders.scala index b875742df..0c215446e 100644 --- a/app/api/Folders.scala +++ b/app/api/Folders.scala @@ -22,6 +22,7 @@ import scala.collection.mutable.ListBuffer class Folders @Inject() ( folders: FolderService, datasets: DatasetService, + collections: CollectionService, files: FileService, events: EventService, routing: ExtractorRoutingService) extends ApiController { @@ -316,6 +317,23 @@ class Folders @Inject() ( if(dataset.files.contains(fileId)) { folders.addFile(newFolder.id, fileId) datasets.removeFile(datasetId, fileId) + + // when moving a file in the root of a dataset inside a folder + // check if that file has been used as thumbnail + // if yes, update the thumbnail of both dataset and collection + if(!file.thumbnail_id.isEmpty && !dataset.thumbnail_id.isEmpty){ + if (file.thumbnail_id.get.equals(dataset.thumbnail_id.get)){ + datasets.newThumbnail(dataset.id) + collections.get(dataset.collections).found.foreach(collection => { + if(!collection.thumbnail_id.isEmpty){ + if(collection.thumbnail_id.get.equals(dataset.thumbnail_id.get)){ + collections.createThumbnail(collection.id) + } + } + }) + } + } + files.index(fileId) datasets.index(datasetId) Ok(toJson(Map("status" -> "success", "fileName" -> file.filename, "folderName" -> newFolder.name)))