public void unlink() throws SQLException { if (linked && fileName != null) { String temp; // synchronize on the database, to avoid concurrent temp file // creation / deletion / backup synchronized (handler) { if (handler.getLobFilesInDirectories()) { temp = getFileName(handler, -1, objectId); } else { // just to get a filename - an empty file will be created temp = handler.createTempFile(); } deleteFile(handler, temp); renameFile(handler, fileName, temp); tempFile = FileStore.open(handler, temp, "rw", null); tempFile.autoDelete(); tempFile.closeSilently(); fileName = temp; linked = false; } } }
private FileStoreOutputStream initLarge(DataHandler handler) throws IOException, SQLException { this.handler = handler; this.tableId = 0; this.linked = false; this.precision = 0; this.small = null; this.hash = 0; String compressionAlgorithm = handler.getLobCompressionAlgorithm(type); this.compression = compressionAlgorithm != null; synchronized (handler) { if (handler.getLobFilesInDirectories()) { objectId = getNewObjectId(handler); fileName = getFileNamePrefix(handler.getDatabasePath(), objectId) + ".temp.db"; } else { objectId = handler.allocateObjectId(false, true); fileName = handler.createTempFile(); } tempFile = handler.openFile(fileName, "rw", false); tempFile.autoDelete(); } FileStoreOutputStream out = new FileStoreOutputStream(tempFile, handler, compressionAlgorithm); return out; }