diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy index a475ad4f..92db5024 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy @@ -33,7 +33,10 @@ class QuiltObserverFactory implements TraceObserverFactory { @Override Collection create(Session session) { //log.debug("`create` ${this}") - return (Collection) [new QuiltObserver()] + Collection quiltObservers = new ArrayList<>() + quiltObservers.add(new QuiltObserver()) + + return quiltObservers as Collection } } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy index b07f5182..6523e71c 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy @@ -51,7 +51,7 @@ class QuiltPathify { Files.copy(source, dest) } catch (Exception e) { - log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`") + log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e") } } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index 7e6369c8..d48ad1d6 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -16,6 +16,7 @@ package nextflow.quilt import nextflow.quilt.jep.QuiltPackage +import nextflow.quilt.jep.QuiltParser import nextflow.quilt.nio.QuiltPath import nextflow.Session @@ -47,14 +48,11 @@ class QuiltProduct { public final static String README_FILE = 'README_NF_QUILT.md' public final static String SUMMARY_FILE = 'quilt_summarize.json' - private final static String KEY_CATALOG = 'catalog' - private final static String KEY_FORCE = 'force' - private final static String KEY_META = 'meta' - private final static String KEY_MSG = 'message' - private final static String KEY_PKG = 'package' - private final static String KEY_QUILT = 'quilt' - private final static String KEY_README = 'readme' - private final static String KEY_SUMMARIZE = 'summarize' + public final static String KEY_META = 'meta' + public final static String KEY_MSG = 'message' + public final static String KEY_QUILT = 'quilt' + public final static String KEY_README = 'readme' + public final static String KEY_SUMMARIZE = 'summarize' /* groovylint-disable-next-line GStringExpressionWithinString */ private final static String DEFAULT_MSG = ''' @@ -112,7 +110,7 @@ ${nextflow} Files.write(path, text.bytes) } catch (Exception e) { - log.error("writeString: cannot write `$text` to `$path` for `${pkg}`") + log.error("writeString: cannot write `$text` to `$path` for `${pkg}`\n$e") } } @@ -123,7 +121,7 @@ ${nextflow} Files.copy(source, dest) } catch (Exception e) { - log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`") + log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e.message()") } } @@ -148,15 +146,17 @@ ${nextflow} ]) QuiltProduct(QuiltPathify pathify, Session session) { + println("Creating QuiltProduct: ${pathify}") this.session = session this.config = session.config ?: [:] this.path = pathify.path + println('QuiltProduct.path') this.pkg = pathify.pkg - println("QuiltProduct.pkg: ${pkg.toUriString()}") + println('QuiltProduct.pkg') this.metadata = getMetadata() - println("QuiltProduct.metadata: ${metadata}") - println("QuiltProduct.flags: ${flags}") - if (session.isSuccess() || flags.getProperty(KEY_FORCE)) { + println('QuiltProduct.metadata') + // println("QuiltProduct.flags: ${flags}") + if (session.isSuccess() || flags.getProperty(QuiltParser.P_FORCE) == true) { publish() } else { log.info("not publishing: ${pkg} [unsuccessful session]") @@ -168,7 +168,7 @@ ${nextflow} log.info("SKIP: metadata for ${pkg}") return [:] } - println("getMetadata.config: ${config}") + // println("getMetadata.config: ${config}") config.remove('executor') config.remove('params') config.remove('session') @@ -181,11 +181,12 @@ ${nextflow} Map cf_meta = quilt_cf.navigate(KEY_META) as Map ?: [:] quilt_cf.remove(KEY_META) - Map pkg_meta = pkg.meta + // println("getMetadata.cf_meta: ${cf_meta}") + Map pkg_meta = pkg.getMetadata() updateFlags(pkg_meta, quilt_cf) Map params = session.getParams() - println("getMetadata.params: ${params}") + // println("getMetadata.params: ${params}") if (params != null) { writeMapToPackage(params, 'params') params.remove('genomes') @@ -193,7 +194,7 @@ ${nextflow} printMap(params, 'params') } Map wf = session.getWorkflowMetadata()?.toMap() - println("getMetadata.wf: ${wf}") + // println("getMetadata.wf: ${wf}") String start = wf?.get('start') String complete = wf?.get('complete') String cmd = wf?.get('commandLine') @@ -209,8 +210,9 @@ ${nextflow} log.info("\npublishing: ${wf['runName']}") } + println("getMetadata.pkg_meta: ${pkg_meta}") Map base_meta = cf_meta + pkg_meta - log.debug("getMetadata.base_meta: ${base_meta}") + log.info("getMetadata.base_meta: ${base_meta}") return base_meta + [ cmd: cmd, now: now(), @@ -228,7 +230,7 @@ ${nextflow} cmd: metadata.get('cmd'), meta: metadata, now: metadata.get('now'), - pkg: flags.getProperty(KEY_PKG) + pkg: flags.getProperty(QuiltParser.P_PKG) ] return params } @@ -245,7 +247,8 @@ ${nextflow} * @param cf Map of config (from nextflow.config) */ void updateFlags(Map meta, Map cf) { - for (String key : flags.properties.keySet()) { + //println("updateFlags.meta: ${meta}") + for (String key : flags.getProperties().keySet()) { if (meta.containsKey(key)) { flags.setProperty(key, meta[key]) } else if (cf.containsKey(key)) { @@ -253,8 +256,8 @@ ${nextflow} } } // FIXME: should this only work for names inferred from S3 URIs? - String pkgName = cf.containsKey(KEY_PKG) ? cf[KEY_PKG] : pkg.packageName - flags.setProperty(KEY_PKG, pkgName) + String pkgName = cf.containsKey(QuiltParser.P_PKG) ? cf[QuiltParser.P_PKG] : pkg.packageName + flags.setProperty(QuiltParser.P_PKG, pkgName) } String writeMapToPackage(Map map, String prefix) { @@ -291,16 +294,23 @@ ${nextflow} } String displayName() { - Object catalog = flags.getProperty(KEY_CATALOG) + Object catalog = flags.getProperty(QuiltParser.P_CAT) return catalog ? pkg.toCatalogURL(catalog.toString()) : pkg.toUriString() } String compileMessage() { String msg = flags.getProperty(KEY_MSG) GStringTemplateEngine engine = new GStringTemplateEngine() - String output = engine.createTemplate(msg).make(getParams()) - log.debug("compileMessage.output: ${output}") - return output + println("compileMessage: ${msg}") + try { + String output = engine.createTemplate(msg).make(getParams()) + log.debug("compileMessage.output: ${output}") + return output + } + catch (Exception e) { + log.error("compileMessage failed: ${e.getMessage()}\n{$e}", flags) + } + return "compileMessage.FAILED\n$msg" } String compileReadme(String msg) { @@ -320,10 +330,16 @@ ${nextflow} nextflow: nextflow, ] log.debug("compileReadme.params: ${params}") - GStringTemplateEngine engine = new GStringTemplateEngine() - String output = engine.createTemplate(raw_readme).make(params) - log.debug("compileReadme.output: ${output}") - return output + try { + GStringTemplateEngine engine = new GStringTemplateEngine() + String output = engine.createTemplate(raw_readme).make(params) + log.debug("compileReadme.output: ${output}") + return output + } + catch (Exception e) { + log.error("compileReadme failed: ${e.getMessage()}\n{$e}", flags) + } + return "compileReadme.FAILED\n$raw_readme" } String writeReadme(String message) { @@ -373,12 +389,14 @@ ${nextflow} List writeSummarize() { List quilt_summarize = [] if (shouldSkip(KEY_SUMMARIZE)) { + log.info("SKIP: summarize for ${flags}") return quilt_summarize } String summarize = flags.getProperty(KEY_SUMMARIZE) String[] wildcards = summarize.split(',') wildcards.each { wildcard -> List paths = match(wildcard) + println("writeSummarize: ${paths.size()} matches for ${wildcard}") paths.each { path -> String filename = path.getFileName() Map entry = ['path': path.toString(), 'title': filename] diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy index 28d9691a..19c867fb 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy @@ -15,9 +15,6 @@ */ package nextflow.quilt.jep -/* groovylint-disable-next-line ImportFromSamePackage */ -import nextflow.quilt.jep.QuiltParser - import groovy.transform.CompileStatic import groovy.util.logging.Slf4j diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy index e0306cfd..d7720cbb 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -22,6 +22,7 @@ import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import java.nio.file.FileSystems import java.nio.file.Files +import java.nio.file.NoSuchFileException import java.nio.file.Path import java.nio.file.Paths import java.nio.file.SimpleFileVisitor @@ -48,8 +49,8 @@ class QuiltPackage { private static final String INSTALL_PREFIX = 'QuiltPackage' static final Path INSTALL_ROOT = Files.createTempDirectory(INSTALL_PREFIX) + public final String packageName private final String bucket - private final String packageName private final QuiltParser parsed private final String hash private final Path folder @@ -97,11 +98,6 @@ class QuiltPackage { PKGS.clear() } - static QuiltPackage forUriString(String uri) { - QuiltParser parsed = QuiltParser.forUriString(uri) - return forParsed(parsed) - } - static QuiltPackage forParsed(QuiltParser parsed) { println("QuiltPackage.forParsed: $parsed") boolean isNull = parsed.hasNullBucket() @@ -123,13 +119,6 @@ class QuiltPackage { return PKGS.containsKey(pkgKey) } - static QuiltPackage forKey(String pkgKey) { - if (hasKey(pkgKey)) { - return PKGS.get(pkgKey) - } - return null - } - static List listDirectory(Path rootPath) { return Files.walk(rootPath).sorted(Comparator.reverseOrder()).collect(Collectors.toList()) } @@ -147,8 +136,8 @@ class QuiltPackage { Files.deleteIfExists(path) } } - catch (java.nio.file.NoSuchFileException e) { - log.debug 'deleteDirectory: ignore non-existent files' + catch (NoSuchFileException e) { + log.debug "deleteDirectory: ignore non-existent files\n$e" } return true } @@ -205,7 +194,7 @@ class QuiltPackage { } boolean is_force() { - return parsed.options[QuiltParser.P_FORCE] + return parsed.getOptions(QuiltParser.P_FORCE) } boolean isNull() { @@ -231,6 +220,10 @@ class QuiltPackage { return folder } + Map getMetadata() { + return this.meta + } + /* * Package methods */ @@ -315,7 +308,7 @@ class QuiltPackage { LocalPhysicalKey physicalKey = new LocalPhysicalKey(f) long size = Files.size(f) builder.addEntry(logicalKey, new Entry(physicalKey, size, null, null)) - }); + }) Map fullMeta = [ 'version': Manifest.VERSION, @@ -337,7 +330,7 @@ class QuiltPackage { /* groovylint-disable-next-line ThrowRuntimeException */ throw new RuntimeException(e) } - return m + // return m } @Override @@ -357,9 +350,4 @@ class QuiltPackage { return parsed.toPackageString(true) } - String meta_overrides(String key, Serializable baseline = null) { - Object temp = meta[key] ? meta[key] : baseline - return temp.toString() - } - } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy index a9123569..4c4495ac 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy @@ -30,19 +30,19 @@ class QuiltParser { static final int MIN_SIZE = 2 static final String NULL_BUCKET = 'nf-quilt-dev-null' - static final String P_CAT = 'catalog' - static final String P_DEST = 'dest' - static final String P_DREG = 'dest-registry' - static final String P_DIR = 'dir' - static final String P_FORCE = 'force' - static final String P_HASH = 'top-hash' - static final String P_PATH = 'path' - static final String P_PKG = 'package' - static final String P_PROP = 'property' - static final String P_REG = 'registry' - static final String P_WORK = 'workflow' - static final String[] INSTALL_KEYS = [P_REG, P_DEST, P_DREG, P_HASH, P_PATH] - static final String[] PUSH_KEYS = [P_REG, P_DIR, P_WORK, P_FORCE] + public static final String P_CAT = 'catalog' + // static final String P_DEST = 'dest' + // static final String P_DREG = 'dest-registry' + // static final String P_DIR = 'dir' + public static final String P_FORCE = 'force' + // static final String P_HASH = 'top-hash' + public static final String P_PATH = 'path' + public static final String P_PKG = 'package' + public static final String P_PROP = 'property' + // static final String P_REG = 'registry' + public static final String P_WORK = 'workflow' + // static final String[] INSTALL_KEYS = [P_REG, P_DEST, P_DREG, P_HASH, P_PATH] + // static final String[] PUSH_KEYS = [P_REG, P_DIR, P_WORK, P_FORCE] private final String bucket private final String packageName @@ -52,11 +52,11 @@ class QuiltParser { private String[] paths private String hash private String tag - private final Map options - private final Map metadata + protected final Map options + protected final Map metadata static QuiltParser forBarePath(String path) { - return QuiltParser.forUriString(PREFIX + path) + return forUriString(PREFIX + path) } static QuiltParser forNullBucket() { @@ -65,7 +65,7 @@ class QuiltParser { static QuiltParser forUriString(String uriString) { URI uri = new URI(uriString) - return QuiltParser.forURI(uri) + return forURI(uri) } static QuiltParser forURI(URI uri) { @@ -92,37 +92,38 @@ class QuiltParser { static Map parseQuery(String query) { if (!query) { return [:] } // skip for urls without query params def params = query.split('&') - def result = [:] + Map result = [:] params.each { param -> def keyValue = param.split('=') if (keyValue.size() == 2) { String key = decode(keyValue[0]) String value = decode(keyValue[1]) if (result.containsKey(key)) { - if (result[key] instanceof List) { - result[key].add(value) + Object listVal = result[key] + if (listVal instanceof List) { + listVal << value } else { - result[key] = [result[key], value] + result[key] = [listVal, value] } } else { result[key] = value } } } - return result + return result as Map } static String encodePair(String key, String value) { - return "${QuiltParser.encode(key)}=${QuiltParser.encode(value)}" + return "${encode(key)}=${encode(value)}" } static String unparseQuery(Map query) { if (!query) { return '' } // skip for urls without query params List params = query.collect { key, value -> if (value instanceof List) { - value.collect { QuiltParser.encodePair(key, it.toString()) }.join('&') + value.collect { encodePair(key, it.toString()) }.join('&') } else { - QuiltParser.encodePair(key, value.toString()) + encodePair(key, value.toString()) } } return params.join('&') @@ -278,7 +279,7 @@ class QuiltParser { } String getOptions(String key) { - return options?.get(key) + return options?.get(key) as String } String toPackageString(boolean forKey = false) { diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy index b51abd42..1b8b4349 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileAttributesView.groovy @@ -49,7 +49,7 @@ class QuiltFileAttributesView implements BasicFileAttributeView { /** * This API is implemented is not supported but instead of throwing an exception just do nothing - * to not break the method {@link java.nio.file.CopyMoveHelper#copyToForeignTarget(...)} + * to not break the method {@link java.nio.file.CopyMoveHelper copyToForeignTarget(...)} * * @param lastModifiedTime * @param lastAccessTime diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy index cf6ffc11..98587d88 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy @@ -58,11 +58,11 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return quiltIDS } - void copy(QuiltPath source, QuiltPath target) { + static void copy(QuiltPath source, QuiltPath target) { throw new UnsupportedOperationException("NOT Implemented 'QuiltFileSystem.copy' `$source` -> `$target`") } - void delete(QuiltPath path) { + static void delete(QuiltPath path) { //log.debug("QuiltFileSystem.delete: $path") path.deinstall() //throw new UnsupportedOperationException("Operation 'delete' is not supported by QuiltFileSystem") @@ -93,7 +93,7 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return QuiltParser.SEP } - QuiltFileAttributesView getFileAttributeView(QuiltPath path) { + static QuiltFileAttributesView getFileAttributeView(QuiltPath path) { //log.debug("QuiltFileAttributesView QuiltFileSystem.getFileAttributeView($path)") String pathString = path.toUriString() try { @@ -105,7 +105,7 @@ final class QuiltFileSystem extends FileSystem implements Closeable { } } - QuiltFileAttributes readAttributes(QuiltPath path) { + static QuiltFileAttributes readAttributes(QuiltPath path) { log.debug("QuiltFileAttributes QuiltFileSystem.readAttributes($path)") Path installedPath = path.localPath() try { @@ -113,12 +113,12 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return new QuiltFileAttributes(path, path.toString(), attrs) } catch (NoSuchFileException e) { - log.debug("No attributes yet for: ${installedPath}") + log.debug("No attributes yet for: ${installedPath}\n$e") } return null } - boolean exists(QuiltPath path) { + static boolean exists(QuiltPath path) { return path.pkg().isInstalled() } @@ -145,15 +145,15 @@ final class QuiltFileSystem extends FileSystem implements Closeable { return new QuiltPath(this, p) } - String toUriString(Path path) { + static String toUriString(Path path) { return path in QuiltPath ? ((QuiltPath)path).toUriString() : null } - String getBashLib(Path path) { + static String getBashLib(Path path) { return path in QuiltPath ? QuiltBashLib.script() : null } - String getUploadCmd(String source, Path target) { + static String getUploadCmd(String source, Path target) { return target in QuiltPath ? QuiltFileCopyStrategy.uploadCmd(source, target) : null } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy index 5ed5ad7e..8c4d664c 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy @@ -34,7 +34,6 @@ import java.nio.file.NoSuchFileException import java.nio.file.OpenOption import java.nio.file.Path import java.nio.file.Paths -import java.nio.file.StandardOpenOption import java.nio.file.attribute.BasicFileAttributeView import java.nio.file.attribute.BasicFileAttributes import java.nio.file.attribute.FileAttribute @@ -94,12 +93,12 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr boolean canUpload(Path source, Path target) { log.debug "QuiltFileSystemProvider.canUpload: ${source} -> ${target}" - return FileSystems.getDefault().equals(source.getFileSystem()) && target instanceof QuiltPath + return FileSystems.getDefault() == source.getFileSystem() && target instanceof QuiltPath } boolean canDownload(Path source, Path target) { log.debug "QuiltFileSystemProvider.canDownload: ${source} -> ${target}" - return source instanceof QuiltPath && FileSystems.getDefault().equals(target.getFileSystem()) + return source instanceof QuiltPath && FileSystems.getDefault() == target.getFileSystem() } void download(Path remoteFile, Path localDestination, CopyOption... options) throws IOException { @@ -161,7 +160,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr return QuiltParser.SCHEME } - String getQuiltIDS(URI uri) { + static String getQuiltIDS(URI uri) { assert uri QuiltParser parsed = QuiltParser.forURI(uri) return parsed.quiltID().toString() @@ -213,6 +212,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr /* groovylint-disable-next-line UnusedMethodParameter */ QuiltFileSystem newFileSystem(String quiltIDS, Map env) throws IOException { + log.debug("newFileSystem $env") final fs = new QuiltFileSystem(quiltIDS, this) fileSystems[quiltIDS] = fs return fs @@ -301,7 +301,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr return new QuiltPath(fs, parsed) } - void checkRoot(Path path) { + static void checkRoot(Path path) { if (path == Paths.get('/')) { throw new UnsupportedOperationException("Operation 'checkRoot' not supported on root path") } @@ -316,7 +316,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr * @return * @throws IOException */ - void notifyFilePublish(QuiltPath destination) { //, Path source=null) { + static void notifyFilePublish(QuiltPath destination) { //, Path source=null) { final sess = Global.session /* groovylint-disable-next-line Instanceof */ if (sess instanceof Session) { @@ -345,12 +345,13 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr FileChannel channel = FileChannel.open(installedPath, options) return channel } - catch (java.nio.file.NoSuchFileException e) { - log.error("Failed `FileChannel.open`: ${installedPath} <- ${options}") + catch (NoSuchFileException e) { + log.error("Failed `FileChannel.open`: ${installedPath} <- ${options}\n$e") } + return null } - DirectoryStream emptyStream() throws IOException { + static DirectoryStream emptyStream() throws IOException { return new DirectoryStream() { @Override @@ -450,32 +451,32 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr } @Override - def V getFileAttributeView(Path path, Class type, LinkOption... options) { + V getFileAttributeView(Path path, Class type, LinkOption... options) { // log.debug("Calling `getFileAttributeView`: ${path}") checkRoot(path) if (type == BasicFileAttributeView || type == QuiltFileAttributesView) { QuiltPath qPath = asQuiltPath(path) - QuiltFileSystem fs = qPath.filesystem + QuiltFileSystem fs = qPath.getFileSystem() as QuiltFileSystem return (V)fs.getFileAttributeView(qPath) } throw new UnsupportedOperationException("Operation 'getFileAttributeView' is not supported for type $type") } @Override - def A readAttributes(Path path, Class type, LinkOption... options) + A readAttributes(Path path, Class type, LinkOption... options) throws IOException { log.debug 'BasicFileAttributes QuiltFileSystemProvider.readAttributes()' def attr = attributesCache.get(path) if (attr) { - return attr + return attr as A } if (type == BasicFileAttributes || type == QuiltFileAttributes) { QuiltPath qPath = asQuiltPath(path) - QuiltFileSystem fs = qPath.filesystem + QuiltFileSystem fs = qPath.getFileSystem() as QuiltFileSystem def result = (A)fs.readAttributes(qPath) if (result) { attributesCache[path] = result - return result + return result as A } log.debug("readAttributes: File ${qPath.localPath()} not found") if (!qPath.isNull()) { @@ -484,7 +485,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr log.warn("readAttributes: Ignore ${qPath} for null bucket") } throw new UnsupportedOperationException("Not a valid Quilt Storage file attribute type: $type") - } + } @Override Map readAttributes(Path path, String attributes, LinkOption... options) throws IOException { diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy index 256e554b..31b09e56 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy @@ -21,6 +21,7 @@ import nextflow.quilt.jep.QuiltParser import java.nio.file.Files import java.nio.file.FileSystem import java.nio.file.LinkOption +import java.nio.file.NoSuchFileException import java.nio.file.Path import java.nio.file.Paths import java.nio.file.ProviderMismatchException @@ -112,10 +113,11 @@ final class QuiltPath implements Path, Comparable { log.debug("QuiltPath.deinstall: $path") try { Files.delete(path) - } catch (java.nio.file.NoSuchFileException e) { + } catch (NoSuchFileException e) { // Handle the exception here log.error("Failed to delete path: $path", e) } + return false } @Override