/** * Assumes that path is relative under root, and constructs a new {@link File} * and calls {@link #RepoFile(File, File)} */ public RepoFile(File root, String path) { this(root, new File(root, norm(path))); }
private OriginalFile update(Session session, final RepoFile repoFile, SqlAction sqlAction, ServiceFactory sf, OriginalFile ofile) { ExperimenterGroup group = loadUserGroup(session); ChecksumAlgorithm hasher = loadChecksum(session, repoFile.hasher().getValue()); ofile.setPath(repoFile.dirname()); ofile.setName(fileRepoSecretKey + repoFile.basename()); ofile.setRepo(uuid); ofile.setHasher(hasher); ofile.setHash(repoFile.hash()); ofile.setSize(repoFile.length()); ofile.getDetails().setGroup(group); setMimetype(ofile); ofile = sf.getUpdateService().saveAndReturnObject(ofile); final String name = ofile.getName(); if (name.startsWith(fileRepoSecretKey)) { ofile.setName(name.substring(fileRepoSecretKey.length())); } return ofile; }
@SuppressWarnings("unchecked") public LutProviderImpl( ScriptRepoHelper scriptRepoHelper, ScriptFileType lutType) { File root = new File(scriptRepoHelper.getScriptDir()); Iterator<File> scripts = FileUtils.iterateFiles( root, lutType.getFileFilter(), TrueFileFilter.TRUE); while (scripts.hasNext()) { RepoFile script = new RepoFile(root, scripts.next()); String basename = script.basename(); try { lutReaders.put( basename, LutReaderFactory.read(script.file())); log.debug("Successfully added LUT '{}'", basename); } catch (Exception e) { log.warn("Cannot read lookup table: '{}'", script.fullname(), e); } } log.info("Successfully added {} LUTs", lutReaders.size()); }
file = new RepoFile(dir, f); Long id = findInDb(sqlAction, file, false); // non-scripts count String hash = null; if (id == null) { if (readOnly.isReadOnlyDb()) { log.info("read-only database so ignoring addition of script {}", file.fullname()); continue; } else { hash = file.hash(); if (!hash.equals(ofile.getHash())) { if (readOnly.isReadOnlyDb()) {
public Long findInDb(final String path, final boolean scriptsOnly) { RepoFile repoFile = new RepoFile(dir, path); return findInDb(repoFile, scriptsOnly); }
public RepoFile write(RepoFile repo, String text) throws IOException { FileUtils.writeStringToFile(repo.file(), text); // truncates itself. ticket:2337 return repo; }
public RepoFile write(String path, String text) throws IOException { RepoFile repo = new RepoFile(dir, path); return write(repo, text); }