public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
private void moveWcDb(File sourceWc, File targetWc) throws SVNException { final File sourceWcDbFile = getWCDbFile(sourceWc); final File targetWcDbFile = getWCDbFile(targetWc); SVNFileUtil.ensureDirectoryExists(targetWcDbFile.getParentFile()); SVNFileUtil.rename(sourceWcDbFile, targetWcDbFile); }
protected void writeCurrentFile(long revision, String nextNodeID, String nextCopyID) throws SVNException, IOException { String line = null; if (getDBFormat() >= FSFS.MIN_NO_GLOBAL_IDS_FORMAT) { line = revision + "\n"; } else { line = revision + " " + nextNodeID + " " + nextCopyID + "\n"; } File currentFile = getCurrentFile(); File tmpCurrentFile = SVNFileUtil.createUniqueFile(currentFile.getParentFile(), currentFile.getName(), ".tmp", false); OutputStream currentOS = null; try { currentOS = SVNFileUtil.openFileForWriting(tmpCurrentFile); currentOS.write(line.getBytes("US-ASCII")); } finally { SVNFileUtil.closeFile(currentOS); } SVNFileUtil.rename(tmpCurrentFile, currentFile); }
private void relegateExternalDir(File wriAbsPath, File localAbsPath) throws SVNException { try { SvnWcDbExternals.removeExternal(getWcContext(), wriAbsPath, localAbsPath); } catch (SVNException e) { if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LEFT_LOCAL_MOD) { File oldName = SVNFileUtil.createUniqueFile(localAbsPath.getParentFile(), localAbsPath.getName(), ".OLD", false); SVNFileUtil.deleteFile(oldName); SVNFileUtil.rename(localAbsPath, oldName); return; } throw e; } }
public void writeFinalCurrentFile(long newRevision, String startNodeId, String startCopyId) throws SVNException, IOException { String[] txnIds = readNextIDs(); String txnNodeId = txnIds[0]; String txnCopyId = txnIds[1]; String newNodeId = FSTransactionRoot.addKeys(startNodeId, txnNodeId); String newCopyId = FSTransactionRoot.addKeys(startCopyId, txnCopyId); String line = newRevision + " " + newNodeId + " " + newCopyId + "\n"; File currentFile = getOwner().getCurrentFile(); File tmpCurrentFile = SVNFileUtil.createUniqueFile(currentFile.getParentFile(), currentFile.getName(), ".tmp"); OutputStream currentOS = null; try { currentOS = SVNFileUtil.openFileForWriting(tmpCurrentFile); currentOS.write(line.getBytes("UTF-8")); } finally { SVNFileUtil.closeFile(currentOS); } SVNFileUtil.rename(tmpCurrentFile, currentFile); }
public static void setProperties(Map namesToValues, File target, File tmpFile, String terminator) throws SVNException { OutputStream dst = null; try { //tmpFile = SVNFileUtil.createUniqueFile(target.getParentFile(), target.getName(), ".tmp"); dst = SVNFileUtil.openFileForWriting(tmpFile); setProperties(namesToValues, dst, terminator); } finally { SVNFileUtil.closeFile(dst); } if (tmpFile != null) { SVNFileUtil.rename(tmpFile, target); SVNFileUtil.setReadonly(target, true); } }
private static void translateFiles(File directory) throws SVNException { File[] children = SVNFileListUtil.listFiles(directory); byte[] eol = new byte[] {'\n'}; for (int i = 0; children != null && i < children.length; i++) { File child = children[i]; File tmpChild = null; if (child.isFile()) { try { tmpChild = SVNFileUtil.createUniqueFile(directory, ".repos", ".tmp", true); SVNTranslator.translate(child, tmpChild, null, eol, null, false, true); SVNFileUtil.deleteFile(child); SVNFileUtil.rename(tmpChild, child); } finally { SVNFileUtil.deleteFile(tmpChild); } } } }
private static void translateFiles(File directory) throws SVNException { File[] children = SVNFileListUtil.listFiles(directory); byte[] eol = new byte[] {'\n'}; for (int i = 0; children != null && i < children.length; i++) { File child = children[i]; File tmpChild = null; if (child.isFile()) { try { tmpChild = SVNFileUtil.createUniqueFile(directory, ".repos", ".tmp", true); SVNTranslator.translate(child, tmpChild, null, eol, null, false, true); SVNFileUtil.deleteFile(child); SVNFileUtil.rename(tmpChild, child); } finally { SVNFileUtil.deleteFile(tmpChild); } } } }
private static void translateFiles(File directory) throws SVNException { File[] children = SVNFileListUtil.listFiles(directory); byte[] eol = new byte[] {'\n'}; for (int i = 0; children != null && i < children.length; i++) { File child = children[i]; File tmpChild = null; if (child.isFile()) { try { tmpChild = SVNFileUtil.createUniqueFile(directory, ".repos", ".tmp", true); SVNTranslator.translate(child, tmpChild, null, eol, null, false, true); SVNFileUtil.deleteFile(child); SVNFileUtil.rename(tmpChild, child); } finally { SVNFileUtil.deleteFile(tmpChild); } } } }
public void setUUID(String uuid) throws SVNException { File uniqueFile = SVNFileUtil.createUniqueFile(getDBRoot(), UUID_FILE, ".tmp", false); uuid += '\n'; OutputStream uuidOS = null; try { uuidOS = SVNFileUtil.openFileForWriting(uniqueFile); uuidOS.write(uuid.getBytes("US-ASCII")); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Error writing repository UUID to ''{0}''", getUUIDFile()); err.setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage())); SVNErrorManager.error(err, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(uuidOS); } SVNFileUtil.rename(uniqueFile, getUUIDFile()); }
public void setUUID(String uuid) throws SVNException { File uniqueFile = SVNFileUtil.createUniqueFile(getDBRoot(), UUID_FILE, ".tmp", false); uuid += '\n'; OutputStream uuidOS = null; try { uuidOS = SVNFileUtil.openFileForWriting(uniqueFile); uuidOS.write(uuid.getBytes("US-ASCII")); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Error writing repository UUID to ''{0}''", getUUIDFile()); err.setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage())); SVNErrorManager.error(err, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(uuidOS); } SVNFileUtil.rename(uniqueFile, getUUIDFile()); }
private void pristineRemoveFile(boolean ignoreEnoent) throws SVNException { if (SVNFileUtil.isWindows) { File temDirAbsPath = getPristineTempDir(root, root.getAbsPath()); File tempAbsPath = SVNFileUtil.createUniqueFile(temDirAbsPath, "pristine", ".tmp", false); try { SVNFileUtil.rename(pristineAbsPath, tempAbsPath); pristineAbsPath = tempAbsPath; } catch (SVNException e){ if (!(ignoreEnoent && SVNFileType.getType(tempAbsPath) == SVNFileType.NONE)) throw e; } } SVNFileUtil.deleteFile(pristineAbsPath); }
public void setUUID(String uuid) throws SVNException { File uniqueFile = SVNFileUtil.createUniqueFile(getDBRoot(), UUID_FILE, ".tmp", false); uuid += '\n'; OutputStream uuidOS = null; try { uuidOS = SVNFileUtil.openFileForWriting(uniqueFile); uuidOS.write(uuid.getBytes("US-ASCII")); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Error writing repository UUID to ''{0}''", getUUIDFile()); err.setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage())); SVNErrorManager.error(err, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(uuidOS); } SVNFileUtil.rename(uniqueFile, getUUIDFile()); }
public static void installPristine(SVNWCDbRoot root, File tempfileAbspath, SvnChecksum sha1Checksum, SvnChecksum md5Checksum) throws SVNException { File pristineAbspath = getPristineFileName(root, sha1Checksum, true); if (pristineAbspath.isFile()) { SVNFileUtil.deleteFile(tempfileAbspath); return; } SVNFileUtil.rename(tempfileAbspath, pristineAbspath); long size = pristineAbspath.length(); SVNSqlJetStatement stmt = root.getSDb().getStatement(SVNWCDbStatements.INSERT_PRISTINE); try { stmt.bindChecksum(1, sha1Checksum); stmt.bindChecksum(2, md5Checksum); stmt.bindLong(3, size); stmt.done(); } finally { stmt.reset(); } }
private void packShard(FSFS fsfs, long shard, boolean packRevisionProperties) throws SVNException { File revShardPath = new File(fsfs.getDBRevsDir(), String.valueOf(shard)); File revpropShardPath = new File(fsfs.getRevisionPropertiesRoot(), String.valueOf(shard)); packRevShard(fsfs, shard, revShardPath); if (packRevisionProperties) { myCanceller.checkCancelled(); packRevPropShard(fsfs, shard, revpropShardPath, (long)(0.9 * fsfs.getRevPropPackSize())); } File finalPath = fsfs.getMinUnpackedRevFile(); File tmpFile = SVNFileUtil.createUniqueFile(fsfs.getDBRoot(), "tempfile", ".tmp", false); String line = String.valueOf((shard + 1) * fsfs.getMaxFilesPerDirectory()) + '\n'; SVNFileUtil.writeToFile(tmpFile, line, "UTF-8"); SVNFileUtil.rename(tmpFile, finalPath); SVNFileUtil.deleteAll(revShardPath, true, myCanceller); if (packRevisionProperties) { deleteRevPropShard(revpropShardPath, shard, fsfs.getMaxFilesPerDirectory()); } firePackEvent(shard, false); }
public void move(SVNWCContext context, File source, File dst, boolean metadataOnly) throws SVNException { boolean moveDegradedToCopy = copy(context, source, dst, true); if (!metadataOnly) { SVNFileUtil.rename(source, dst); } Structure<NodeInfo> nodeInfo = context.getDb().readInfo(source, NodeInfo.kind, NodeInfo.conflicted); if (nodeInfo.get(NodeInfo.kind) == SVNWCDbKind.Dir) { removeAllConflictMarkers(context.getDb(), source, dst); } if (nodeInfo.is(NodeInfo.conflicted)) { removeAllConflictMarkers(context.getDb(), source, dst); } SvnNgRemove.delete(getWcContext(), source, moveDegradedToCopy ? null : dst, true, false, this); }
public void runOperation(SVNWCContext ctx, File wcRootAbspath, SVNSkel workItem) throws SVNException { File localAbspath = SVNFileUtil.createFilePath(wcRootAbspath, workItem.getChild(1).getValue()); SVNSkel conflicts = ctx.getDb().readConflict(localAbspath); Structure<SvnWcDbConflicts.PropertyConflictInfo> propertyConflictInfo = SvnWcDbConflicts.readPropertyConflict(ctx.getDb(), wcRootAbspath, conflicts); File prejfileAbspath = propertyConflictInfo.get(SvnWcDbConflicts.PropertyConflictInfo.markerAbspath); SVNSkel conflictSkel = null; if (workItem.getListSize() > 2) { conflictSkel = workItem.getChild(2); } else { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ASSERTION_FAIL); SVNErrorManager.error(err, SVNLogType.WC); } File tmpPrejfileAbspath = ctx.createPrejFile(localAbspath, conflictSkel); assert (prejfileAbspath != null); SVNFileUtil.rename(tmpPrejfileAbspath, prejfileAbspath); } }