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

Andrew Su asu at redhat.com
Wed Apr 20 13:45:11 PDT 2011


----- Original Message -----
> From: "Deepak Bhole" <dbhole at redhat.com>
> To: "Andrew Su" <asu at redhat.com>
> Cc: "IcedTea" <distro-pkg-dev at openjdk.java.net>
> Sent: Wednesday, April 20, 2011 4:06:52 PM
> Subject: Re: [rfc][icedtea-web]: Update recently_used when removing items with itw-settings
> * 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.

ah ok.

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

I've moved the removing entry from our lru to be called only after a delete succeeds. If for any other reason that delete fails we can ignore it (or maybe inform the user).

> 
> 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?
> 

The last line is to delete the info file associated with the entry.


ChangeLog:
2011-04-20  Andrew Su  <asu at redhat.com>

        * netx/net/sourceforge/jnlp/controlpanel/CachePane.java:
        (createButtonPanel): Changed to update the recently_used file to
        reflect the deletion. Added method updateRecentlyUsed to anonymous
        ActionListener class which will do the actual updating.

> 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);
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch4.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20110420/04a887b8/patch4.patch 


More information about the distro-pkg-dev mailing list