public TranscodeFileImpl lookupFile(TranscodeProfile profile, DiskManagerFileInfo file) { try { synchronized (this) { if (device_files == null) { loadDeviceFile(); } String key = ByteFormatter.encodeString(file.getDownloadHash()) + ":" + file.getIndex() + ":" + profile.getUID(); if (device_files.containsKey(key)) { try { return (new TranscodeFileImpl(this, key, device_files)); } catch (Throwable e) { device_files.remove(key); log("Failed to deserialise transcode file", e); } } } } catch (Throwable e) { } return (null); }
public void setDefaultTranscodeProfile(TranscodeProfile profile) { if (profile == null) { removePersistentProperty(PP_REND_DEF_TRANS_PROF); } else { setPersistentStringProperty(PP_REND_DEF_TRANS_PROF, profile.getUID()); } }
public TranscodeFileImpl allocateFile( TranscodeProfile profile, boolean no_xcode, DiskManagerFileInfo file, boolean for_job) throws TranscodeException { TranscodeFileImpl result = null; setError(KEY_FILE_ALLOC_ERROR, null); try { synchronized (this) { if (device_files == null) { loadDeviceFile(); } String key = ByteFormatter.encodeString(file.getDownloadHash()) + ":" + file.getIndex() + ":" + profile.getUID(); if (device_files.containsKey(key)) { try { result = new TranscodeFileImpl(this, key, device_files); } catch (Throwable e) { device_files.remove(key); log("Failed to deserialise transcode file", e); } } if (result == null) { String ext = profile.getFileExtension(); String target_file = file.getFile(true).getName(); if (ext != null && !no_xcode) { int pos = target_file.lastIndexOf('.'); if (pos != -1) { target_file = target_file.substring(0, pos); } target_file += ext; } target_file = allocateUniqueFileName(target_file); File output_file = getWorkingDirectory(true); if (!output_file.canWrite()) { throw (new TranscodeException( "Can't write to transcode folder '" + output_file.getAbsolutePath() + "'")); } output_file = new File(output_file.getAbsoluteFile(), target_file); result = new TranscodeFileImpl( this, key, profile.getName(), device_files, output_file, for_job); result.setSourceFile(file); device_files_last_mod = SystemTime.getMonotonousTime(); device_files_dirty = true; } else { result.setSourceFile(file); result.setProfileName(profile.getName()); } } } catch (Throwable e) { setError(KEY_FILE_ALLOC_ERROR, Debug.getNestedExceptionMessage(e)); throw (new TranscodeException("File allocation failed", e)); } for (TranscodeTargetListener l : listeners) { try { l.fileAdded(result); } catch (Throwable e) { Debug.out(e); } } return (result); }