[rfc][icedtea-web]: Update recently_used when removing items with itw-settings

Deepak Bhole dbhole at redhat.com
Wed Apr 20 13:06:52 PDT 2011


* Andrew Su <asu at redhat.com> [2011-04-20 15:40]:
> Hello,
> 
> When deleting a cached item from itw-settings recently_used would not get updated.
> This patch will change that behavior and update accordingly.
>

Please post changelogs with all your patches in the future.

What happens is delete fails for some reason? Wouldn't the entry get
removed incorrectly and become untracked?

Also, I noticed that the code below is doing this:
   if (fileNode.getFile().delete()) {
       fileNode.getParent().removeChild(fileNode);
       FileUtils.deleteWithErrMesg(fileNode.getInfoFile());
       ...

Isn't the last line trying to re-delete the file?

Cheers,
Deepak
 
> Cheers,
>  Andrew

> diff -r ad820e40fe56 netx/net/sourceforge/jnlp/controlpanel/CachePane.java
> --- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java	Wed Apr 20 15:02:56 2011 -0400
> +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java	Wed Apr 20 15:31:12 2011 -0400
> @@ -32,6 +32,7 @@
>  import java.nio.channels.FileLock;
>  import java.text.SimpleDateFormat;
>  import java.util.ArrayList;
> +import java.util.Enumeration;
>  import java.util.List;
>  
>  import javax.swing.JButton;
> @@ -48,6 +49,7 @@
>  import net.sourceforge.jnlp.config.DeploymentConfiguration;
>  import net.sourceforge.jnlp.runtime.Translator;
>  import net.sourceforge.jnlp.util.FileUtils;
> +import net.sourceforge.jnlp.util.PropertiesFile;
>  
>  public class CachePane extends JPanel {
>  
> @@ -152,6 +154,9 @@
>                          return;
>                      int modelRow = cacheTable.convertRowIndexToModel(row);
>                      DirectoryNode fileNode = ((DirectoryNode) cacheTable.getModel().getValueAt(modelRow, 0));
> +
> +                    updateRecentlyUsed(fileNode.getFile());
> +
>                      if (fileNode.getFile().delete()) {
>                          fileNode.getParent().removeChild(fileNode);
>                          FileUtils.deleteWithErrMesg(fileNode.getInfoFile());
> @@ -172,6 +177,20 @@
>                      }
>                  }
>              }
> +
> +            private void updateRecentlyUsed(File f) {
> +                File recentlyUsedFile = new File(location + File.separator + "recently_used");
> +                PropertiesFile pf = new PropertiesFile(recentlyUsedFile);
> +                pf.load();
> +                Enumeration<Object> en = pf.keys();
> +                while (en.hasMoreElements()) {
> +                    String key = (String) en.nextElement();
> +                    if (pf.get(key).equals(f.getAbsolutePath())) {
> +                        pf.remove(key);
> +                    }
> +                }
> +                pf.store();
> +            }
>          });
>          buttons.add(deleteButton);
>  




More information about the distro-pkg-dev mailing list