Skip to content

Commit fbfadfc

Browse files
authored
Merge pull request #261 from clowder-framework/cilogon-save-file
cilogon less verbose + more logs for save error
2 parents e7b91eb + 215b64b commit fbfadfc

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## 1.18.1 - 2021-08-16
88

9+
This release fixes a critical issue where invalid zip files could result in the files not being uploaded correctly. To check to see if you are affected, please use the following query:
10+
11+
```
12+
db.uploads.find({"status": "CREATED", "contentType": "multi/files-zipped"})
13+
```
14+
15+
If any files are returned, you should check to see if these files affected and are missing from clowder.
16+
917
### Fixed
18+
- When zip file is uploaded, it will parse the file to check if it is a valid zip file, this couuld result in files not stored in final storage space [#264](https://github.com/clowder-framework/clowder/issues/264)
1019
- Updated swagger documentation
1120
- Return 404 not found when calling file/dataset/space api endpoints with an invalid ID [#251](https://github.com/clowder-framework/clowder/issues/251)
1221

22+
### Changed
23+
- Added more information when writing files to make sure files are written correctly
24+
- Made cilogon group check debug message instead of error message
25+
1326
## 1.18.0 - 2021-07-08
1427

1528
### Added

app/fileutils/FilesUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ else if(!fileName.toLowerCase().endsWith(".ptm")){
7171
if(allPTMsFlag.equals("found"))
7272
return "multi/files-ptm-zipped";
7373

74-
} catch (IOException e) {
75-
// TODO Auto-generated catch block
74+
} catch (Throwable e) {
75+
Logger.error("Could not read zipfile", e);
7676
return ("ERROR: " + e.getMessage());
7777
}
7878
return mainFileType;

app/services/CILogonProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CILogonProvider(application: Application) extends OAuth2Provider(applicati
5757
}
5858
}
5959
case (Some(_), None) => throw new AuthenticationException()
60-
case (None, _) => Logger.error("[securesocial] No check needed for groups")
60+
case (None, _) => Logger.debug("[securesocial] No check needed for groups")
6161
}
6262
user.copy(
6363
identityId = IdentityId(userId, id),

app/util/FileUtils.scala

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,19 @@ object FileUtils {
399399
val fileExecutionContext: ExecutionContext = Akka.system().dispatchers.lookup("akka.actor.contexts.file-processing")
400400
Future {
401401
try {
402-
saveFile(file, f.ref.file, originalZipFile, clowderurl, apiKey, Some(user)).foreach { fixedfile =>
403-
processFileBytes(fixedfile, f.ref.file, dataset)
404-
files.setStatus(fixedfile.id, FileStatus.UPLOADED)
405-
sinkService.logFileUploadEvent(fixedfile, dataset, Option(user))
406-
processFile(fixedfile, clowderurl, index, flagsFromPrevious, showPreviews, dataset, runExtractors, apiKey)
407-
processDataset(file, dataset, folder, clowderurl, user, index, runExtractors, apiKey)
408-
files.setStatus(fixedfile.id, FileStatus.PROCESSED)
402+
saveFile(file, f.ref.file, originalZipFile, clowderurl, apiKey, Some(user)) match {
403+
case Some(fixedfile) => {
404+
processFileBytes(fixedfile, f.ref.file, dataset)
405+
files.setStatus(fixedfile.id, FileStatus.UPLOADED)
406+
sinkService.logFileUploadEvent(fixedfile, dataset, Option(user))
407+
processFile(fixedfile, clowderurl, index, flagsFromPrevious, showPreviews, dataset, runExtractors, apiKey)
408+
processDataset(file, dataset, folder, clowderurl, user, index, runExtractors, apiKey)
409+
files.setStatus(fixedfile.id, FileStatus.PROCESSED)
410+
}
411+
case None => Logger.error(s"File was not saved for ${file.id}, saveFile returned None")
409412
}
413+
} catch {
414+
case e: Throwable => Logger.error(s"File was not saved for ${file.id}", e)
410415
} finally {
411416
f.ref.clean()
412417
}
@@ -455,12 +460,19 @@ object FileUtils {
455460
// process rest of file in background
456461
val fileExecutionContext: ExecutionContext = Akka.system().dispatchers.lookup("akka.actor.contexts.file-processing")
457462
Future {
458-
saveURL(file, url, clowderurl, apiKey, Some(user)).foreach { fixedfile =>
459-
processFileBytes(fixedfile, new java.io.File(path), fileds)
460-
files.setStatus(fixedfile.id, FileStatus.UPLOADED)
461-
processFile(fixedfile, clowderurl, index, flagsFromPrevious, showPreviews, fileds, runExtractors, apiKey)
462-
processDataset(file, fileds, folder, clowderurl, user, index, runExtractors, apiKey)
463-
files.setStatus(fixedfile.id, FileStatus.PROCESSED)
463+
try {
464+
saveURL(file, url, clowderurl, apiKey, Some(user)) match{
465+
case Some(fixedfile) => {
466+
processFileBytes(fixedfile, new java.io.File(path), fileds)
467+
files.setStatus(fixedfile.id, FileStatus.UPLOADED)
468+
processFile(fixedfile, clowderurl, index, flagsFromPrevious, showPreviews, fileds, runExtractors, apiKey)
469+
processDataset(file, fileds, folder, clowderurl, user, index, runExtractors, apiKey)
470+
files.setStatus(fixedfile.id, FileStatus.PROCESSED)
471+
}
472+
case None => Logger.error(s"File was not saved for ${file.id}, saveFile returned None")
473+
}
474+
} catch {
475+
case e: Throwable => Logger.error(s"File was not saved for ${file.id}", e)
464476
}
465477
}(fileExecutionContext)
466478

0 commit comments

Comments
 (0)