/hg/icedtea-web: Check if cache directory is writable from itweb...
asu at icedtea.classpath.org
asu at icedtea.classpath.org
Mon May 30 11:04:34 PDT 2011
changeset 03f8f75457dc in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=03f8f75457dc
author: Andrew Su <asu at redhat.com>
date: Mon May 30 14:03:23 2011 -0400
Check if cache directory is writable from itweb-settings
diffstat:
ChangeLog | 6 ++
netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java | 23 +++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diffs (62 lines):
diff -r 4393a8c5101a -r 03f8f75457dc ChangeLog
--- a/ChangeLog Mon May 30 13:50:35 2011 -0400
+++ b/ChangeLog Mon May 30 14:03:23 2011 -0400
@@ -1,3 +1,9 @@
+2011-05-30 Andrew Su <asu at redhat.com>
+
+ * netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java:
+ (addComponent): Add check to see if specified cache directory is
+ writable.
+
2011-05-30 Andrew Su <asu at redhat.com>
* netx/net/sourceforge/jnlp/cache/ResourceTracker.java:
diff -r 4393a8c5101a -r 03f8f75457dc netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Mon May 30 13:50:35 2011 -0400
+++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Mon May 30 14:03:23 2011 -0400
@@ -26,6 +26,7 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.io.File;
import javax.swing.JButton;
import javax.swing.JCheckBox;
@@ -33,6 +34,7 @@
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JSpinner;
@@ -109,10 +111,27 @@
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ fileChooser.setFileHidingEnabled(false);
if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
+ // Check if we have permission to write to that location.
String result = fileChooser.getSelectedFile().getAbsolutePath();
- location.setText(result);
- config.setProperty(properties[1], result);
+ File dirLocation = new File(result);
+ boolean canWrite = dirLocation.canWrite();
+ while (!canWrite && dirLocation != null){ // File does not exist, or no permission.
+
+ if (dirLocation.exists()) {
+ JOptionPane.showMessageDialog(null, "No permission to write to this location.");
+ return;
+ }
+
+ dirLocation = dirLocation.getParentFile();
+ canWrite = dirLocation.canWrite();
+ }
+
+ if (canWrite) {
+ location.setText(result);
+ config.setProperty(properties[1], result);
+ }
}
}
});
More information about the distro-pkg-dev
mailing list