From b146b5ba0d1fa2dd0e5a431ee6f91d64b351a3b1 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 6 Oct 2021 16:41:17 -0500 Subject: [PATCH 1/3] fix --- app/api/Folders.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/api/Folders.scala b/app/api/Folders.scala index b875742df..c427339b9 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,25 @@ 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))) From 5741a082f048be9007ae4f4aad867f0c9ddb2dcd Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 6 Oct 2021 16:41:54 -0500 Subject: [PATCH 2/3] fix format --- app/api/Folders.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/api/Folders.scala b/app/api/Folders.scala index c427339b9..0c215446e 100644 --- a/app/api/Folders.scala +++ b/app/api/Folders.scala @@ -333,8 +333,6 @@ class Folders @Inject() ( }) } } - } - } files.index(fileId) datasets.index(datasetId) From c134f83c1c91346af642b8b62dc54e3b713e96c7 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 6 Oct 2021 16:56:23 -0500 Subject: [PATCH 3/3] add entry in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa3955f0c..7095d7034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Can add dataset to spaces - fixed error when no spaces would load. [#274](https://github.com/clowder-framework/clowder/issues/274) - Typos "success" when returning status from API and "occurred" when logging to console. - If a dataset had multiple folders the layout would be wrong. +- Fix the broken link after file deletion within a folder. [#277](https://github.com/clowder-framework/clowder/issues/277) ### Added - Adding mime type for geojson