Skip to content

Commit

Permalink
Merge pull request #288 from clowder-framework/277-Dataset-Thumbnail-…
Browse files Browse the repository at this point in the history
…404-Not-Found---Broken-Link-after-File-Deletion

277 dataset thumbnail 404 not found   broken link after file deletion
  • Loading branch information
max-zilla committed Oct 19, 2021
2 parents 276434f + a19249c commit e7cb546
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions app/api/Folders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit e7cb546

Please sign in to comment.