Skip to content

Instantly share code, notes, and snippets.

@phette23
Created May 8, 2018 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/5ded48ef3df4d677a1355e3e5abd70a5 to your computer and use it in GitHub Desktop.
Save phette23/5ded48ef3df4d677a1355e3e5abd70a5 to your computer and use it in GitHub Desktop.
// check if an item's staging directory contains the same files as its persistent storage does
function log(msg) {
logger.log(currentItem.getUuid() + "/" + currentItem.getVersion() + " LOGGER: " + msg);
}
// use staging API to check those files
if (staging.isAvailable()) {
var stagingFilesAndDirs = staging.listFiles("", "**");
for(var i = 0; i < stagingFilesAndDirs.size(); i++) {
log(stagingFilesAndDirs.get(i));
}
} else {
log('ERROR, staging not available')
}
var filestore = "/mnt/equelladata01/Institutions/cca2012/Attachments/"
// List the files in the persistent folder
log("Listing the item's persistent files:")
var hash = currentItem.getUuid().hashCode() & 127
var persistentStoragePath = filestore + hash + "/" + currentItem.getUuid() + "/" + currentItem.getVersion()
var cmd = system.execute("ls", [persistentStoragePath])
var stderr = cmd.getErrorOutput()
var stdout = cmd.getStandardOutput()
if (stderr != '') log('ERROR - ' + stderr)
if (stdout != '') log('Files - ' + stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment