Navigation Menu

Skip to content

Commit

Permalink
#1956. Also remove temporary QL files.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Apr 19, 2008
1 parent 9892fb5 commit b2dace2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
7 changes: 7 additions & 0 deletions source/ch/cyberduck/core/Collection.java
Expand Up @@ -88,6 +88,13 @@ public boolean contains(Object o) {
return super.contains(o);
}

public void clear() {
for(Iterator iter = this.iterator(); iter.hasNext(); ) {
this.collectionItemRemoved(iter.next());
}
super.clear();
}

/**
*
* @param row
Expand Down
37 changes: 6 additions & 31 deletions source/ch/cyberduck/core/Local.java
Expand Up @@ -302,31 +302,15 @@ public boolean touch() {
// }

/**
* @param recursively If true, descend into directories and delete recursively
* @return <code>true</code> if and only if the file or directory is
* successfully deleted; <code>false</code> otherwise
* Moves the file to the Trash. NSWorkspace.RecycleOperation
*/
public boolean delete(boolean recursively) {
if(!recursively) {
return _impl.delete();
}
return this.deleteImpl(_impl);
}

/**
* Recursively deletes this file
*
* @return <code>true</code> if and only if the file or directory is
* successfully deleted; <code>false</code> otherwise
*/
private boolean deleteImpl(File f) {
if(f.isDirectory()) {
File[] files = f.listFiles();
for(int i = 0; i < files.length; i++) {
this.deleteImpl(files[i]);
public void delete() {
if(this.exists()) {
if(0 > NSWorkspace.sharedWorkspace().performFileOperation(NSWorkspace.RecycleOperation,
this.getParent().getAbsolute(), "", new NSArray(this.getName()))) {
log.warn("Failed to move " + this.getAbsolute() + " to Trash");
}
}
return f.delete();
}

/**
Expand Down Expand Up @@ -447,15 +431,6 @@ public void run() {
});
}

public void delete() {
if(this.exists()) {
if(0 > NSWorkspace.sharedWorkspace().performFileOperation(NSWorkspace.RecycleOperation,
this.getParent().getAbsolute(), "", new NSArray(this.getName()))) {
log.warn("Failed to move " + this.getAbsolute() + " to Trash");
}
}
}

public void rename(String name) {
_impl.renameTo(new File(this.getParent().getAbsolute(), name));
this.setPath(this.getParent().getAbsolute(), name);
Expand Down
22 changes: 13 additions & 9 deletions source/ch/cyberduck/core/Path.java
Expand Up @@ -250,6 +250,7 @@ public Host getHost() {

/**
* Accessability for #getSession.cache()
*
* @return
*/
public Cache cache() {
Expand Down Expand Up @@ -352,7 +353,7 @@ public Local getLocal() {
}
return this.local;
}

private Local getDefaultLocal() {
return new Local(this.getHost().getDownloadFolder(), this.getName());
}
Expand Down Expand Up @@ -391,7 +392,6 @@ public void download() {
}

/**
*
* @param check Check for open connection and open if needed before transfer
*/
public void download(final boolean check) {
Expand All @@ -407,17 +407,16 @@ public void download(StreamListener listener) {

/**
* @param throttle The bandwidth limit
* @param listener
* @param listener The stream listener to notify about bytes received and sent
*/
public void download(BandwidthThrottle throttle, StreamListener listener) {
this.download(throttle, listener, false);
}

/**
*
* @param throttle
* @param listener
* @param check Check for open connection and open if needed before transfer
* @param throttle The bandwidth limit
* @param listener The stream listener to notify about bytes received and sent
* @param check Check for open connection and open if needed before transfer
*/
public abstract void download(BandwidthThrottle throttle, StreamListener listener, boolean check);

Expand All @@ -435,6 +434,10 @@ public void upload(StreamListener listener) {
this.upload(new BandwidthThrottle(BandwidthThrottle.UNLIMITED), listener);
}

/**
* @param throttle The bandwidth limit
* @param listener The stream listener to notify about bytes received and sent
*/
public void upload(BandwidthThrottle throttle, StreamListener listener) {
Permission p = null;
if(Preferences.instance().getBoolean("queue.upload.changePermissions")) {
Expand All @@ -455,14 +458,15 @@ public void upload(BandwidthThrottle throttle, StreamListener listener) {
}
}
}
this.upload(throttle, listener, p, false);
this.upload(throttle, listener, p, false);
this.getParent().invalidate();
}

/**
* @param throttle The bandwidth limit
* @param listener The stream listener to notify about bytes received and sent
* @param p The permission to set after uploading or null
* @param p The permission to set after uploading or null
* @param check Check for open connection and open if needed before transfer
*/
public abstract void upload(BandwidthThrottle throttle, StreamListener listener, Permission p, boolean check);

Expand Down
26 changes: 22 additions & 4 deletions source/ch/cyberduck/ui/cocoa/CDBrowserController.java
Expand Up @@ -1085,6 +1085,22 @@ private void browserSwitchClicked(final int selected) {
}

private class AbstractBrowserTableDelegate extends CDAbstractTableDelegate {

private Collection temporaryQuickLookFiles = new Collection() {
public void collectionItemRemoved(Object o) {
((Local)o).delete();
}
};


public AbstractBrowserTableDelegate() {
CDBrowserController.this.addListener(new CDWindowListener() {
public void windowWillClose() {
temporaryQuickLookFiles.clear();
}
});
}

public boolean isColumnEditable(NSTableColumn column) {
if(Preferences.instance().getBoolean("browser.editable")) {
if(column.identifier().equals(CDBrowserTableDataSource.FILENAME_COLUMN)) {
Expand Down Expand Up @@ -1114,7 +1130,7 @@ public void spaceKeyPressed(final Object sender) {
}

private void updateQuickLookSelection(final Collection selected) {
final Collection downloads = new Collection();
final Collection downloads = new Collection();
for(Iterator iter = selected.iterator(); iter.hasNext();) {
final Path path = (Path) iter.next();
if(!path.attributes.isFile()) {
Expand All @@ -1131,18 +1147,20 @@ private void updateQuickLookSelection(final Collection selected) {
public void run() {
for(Iterator iter = downloads.iterator(); iter.hasNext();) {
final Path preview = (Path) iter.next();
if(!preview.getLocal().exists()) {
if(preview.getLocal().attributes.getSize() != preview.attributes.getSize()) {
preview.download(true);
}
}
}

public void cleanup() {
final List previews = new ArrayList();
final Collection previews = new Collection();
for(Iterator iter = downloads.iterator(); iter.hasNext();) {
final Path download = (Path) iter.next();
previews.add(download.getLocal());
}
// Keep references to delete later
temporaryQuickLookFiles.addAll(previews);
// Change files in Quick Look
QuickLook.select((Local[]) previews.toArray(new Local[previews.size()]));
// Open Quick Look Preview Panel
Expand Down Expand Up @@ -2402,7 +2420,7 @@ public TransferAction prompt() {
}
}
finally {
local.delete(true);
local.delete();
}
}
}
Expand Down

0 comments on commit b2dace2

Please sign in to comment.