if (nfsFile.isDirectory()) { synchronized (this) { F metaDir = getMetaFile(nfsFile).getParentFile();
/** * Get the nfsFile holding the metadata for this nfsFile. * * @param nfsFile the nfsFile * @return the nfsFile holding the metadata * @throws IOException */ private F getMetaFile(F nfsFile) throws IOException { try { if (!nfsFile.isDirectory()) { return nfsFile.getParentFile().newChildFile(ObjectMetadata.METADATA_DIR).newChildFile(nfsFile.getName()); } else { return nfsFile.newChildFile(ObjectMetadata.METADATA_DIR).newChildFile(ObjectMetadata.DIR_META_FILE); } } catch (IOException e) { throw new ConfigurationException(e); } }
/** * Create an ObjectSummary for the nfsFile. * * @param nfsFile the nfsFile * @return the summary */ private ObjectSummary createSummary(F nfsFile) { try { if (!nfsFile.exists()) { throw new ObjectNotFoundException(nfsFile.getPath()); } boolean link = isSymLink(nfsFile); boolean directory = nfsFile.isDirectory() && (config.isFollowLinks() || !link); long size = directory || link ? 0 : nfsFile.length(); return new ObjectSummary(nfsFile.getAbsolutePath(), directory, size); } catch (IOException e) { throw new ConfigurationException(e); } }
public SyncObject loadObject(final String identifier) throws ObjectNotFoundException { final F nfsFile; final boolean isDirectory; ObjectMetadata metadata; try { nfsFile = createFile(identifier); isDirectory = nfsFile.isDirectory(); metadata = readMetadata(nfsFile); } catch (IOException e) { throw new ObjectNotFoundException(e); } LazyValue<InputStream> lazyStream = new LazyValue<InputStream>() { @Override public InputStream get() { return readDataStream(nfsFile); } }; LazyValue<ObjectAcl> lazyAcl = new LazyValue<ObjectAcl>() { @Override public ObjectAcl get() { return readAcl(nfsFile); } }; SyncObject object = new SyncObject(this, getRelativePath(identifier, isDirectory), metadata).withLazyStream(lazyStream) .withLazyAcl(lazyAcl); object.setProperty(PROP_FILE, nfsFile); return object; }
boolean directory = nfsFile.isDirectory();