Skip to content

Commit e7cb546

Browse files
authored
Merge pull request #288 from clowder-framework/277-Dataset-Thumbnail-404-Not-Found---Broken-Link-after-File-Deletion
277 dataset thumbnail 404 not found broken link after file deletion
2 parents 276434f + a19249c commit e7cb546

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111
for passing in credentials to the S3ByteStorageService.
1212

1313
### Fixed
14+
- Upgraded extractor parameters jsonform to version `2.2.5`.
1415
- Cleaning up after a failed upload should no longer decrement the file + byte counts.
16+
- Fix the broken link after file deletion within a folder. [#277](https://github.com/clowder-framework/clowder/issues/277)
1517

1618
### Changed
1719
- now building mongo-init and monitor docker containers with python 3.8

app/api/Folders.scala

Lines changed: 18 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,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

Comments
 (0)