public FileBuffer() { this(TemporaryFileServiceFactory.get().create(new AlphanumericRandomStringService().random())); }
TemporaryFileServiceFactory.get().shutdown();
/** * Write temporary file with data * * @param icon Base64 encoded image information * @return Path to file */ private Local write(final String icon) { if(StringUtils.isBlank(icon)) { return null; } final byte[] favicon = Base64.decodeBase64(icon); final Local file = TemporaryFileServiceFactory.get().create(new AlphanumericRandomStringService().random()); try { new DefaultLocalTouchFeature().touch(file); final OutputStream out = file.getOutputStream(false); try { IOUtils.write(favicon, out); } finally { IOUtils.closeQuietly(out); } return file; } catch(IOException | AccessDeniedException e) { log.error("Error writing temporary file", e); } return null; }
/** * Quits the Rendezvous daemon and saves all preferences * * @param notification Notification name */ @Override public void applicationWillTerminate(NSNotification notification) { if(log.isDebugEnabled()) { log.debug(String.format("Application will quit with notification %s", notification)); } this.invalidate(); // Clear temporary files TemporaryFileServiceFactory.get().shutdown(); //Terminating rendezvous discovery RendezvousFactory.instance().quit(); // Remove notifications from center NotificationServiceFactory.get().unregister(); // Disable update updater.unregister(); //Writing usage info preferences.setProperty("uses", preferences.getInteger("uses") + 1); preferences.save(); DefaultBackgroundExecutor.get().shutdown(); }
private void updateQuickLookSelection(final List<Path> selected) { final List<TransferItem> downloads = new ArrayList<TransferItem>(); for(Path file : selected) { if(!file.isFile()) { continue; } downloads.add(new TransferItem(file, TemporaryFileServiceFactory.get().create(pool.getHost().getUuid(), file))); } if(downloads.size() > 0) { final Transfer download = new DownloadTransfer(pool.getHost(), downloads); final TransferOptions options = new TransferOptions(); this.background(new QuicklookTransferBackgroundAction(this, quicklook, pool, download, options, downloads)); } }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { final Local temp = TemporaryFileServiceFactory.get().create(file); LocalTouchFactory.get().touch(temp); try { final T reply = feature.upload(file, temp, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); if(log.isDebugEnabled()) { log.debug(String.format("Received reply %s for creating file %s", reply, file)); } return new Path(file.getParent(), file.getName(), file.getType(), attributes.find(file)); } finally { temp.delete(); } }
public AbstractEditor(final Application application, final SessionPool session, final Path file, final ApplicationLauncher launcher, final ApplicationFinder finder, final ProgressListener listener) { this.applicationLauncher = launcher; this.applicationFinder = finder; this.application = application; if(file.isSymbolicLink() && PreferencesFactory.get().getBoolean("editor.upload.symboliclink.resolve")) { this.remote = file.getSymlinkTarget(); } else { this.remote = file; } this.local = TemporaryFileServiceFactory.get().create(session.getHost().getUuid(), remote); this.session = session; this.listener = listener; }