While writing some Unit Tests for Janitor code,  I think some of the
location of the user/cache folder may be causing some confusion in Janitor
/ Places code.  Up front, sorry for the length and not sure if any of this
is an issue with how the unit tests "setup of the user/cache" directories
is written or may highlight an actual code issue.

>From Netbeans...Help, the folders show

*User directory:* <%USERPROFILE%>\AppData\Roaming\NetBeans\<version>

*Cache directory:*  <%USERPROFILE%> \AppData\Local\NetBeans\Cache\<version>


On local Windows install, the cache seems to be in location like
%USERPROFILE%\AppData\Local\NetBeans\Cache\<versions> ) compared to user in
slightly different location at
%USERPROFILE%\AppData\Roaming\NetBeans\<versions> so the "cache" does not
appear to be a subfolder under user directory and the "version" subfolder
may also be in different areas.

Is the "cache" (and user) location different on Windows vs non-Windows?  On
"non-windows" is it expected under <netbeans.user>/version/var/cache vs
"windows" under a different location (i.e.
"%USERPROFILE%\AppData\Local\NetBeans\Cache\<versions>")?  Is the "cache"
supposed to be a sub-directory of the "netbeans.user" or separate location
(i.e. <netbeans.user>/<version>/<Cache> or <netbeans.user>/Cache)?

Could this sort of differences in location cause problems with the Janitor
cache and other things (i.e. when importing values from older versions
maybe it's trying to pull and can't find it because it's in an inconsistent
location)?

If the "netbeans.user" points to a <version> subfolder, and the cache is a
subfolder under the folder, then would there not be a
<netbeans.user>/<version>/var/cache/<version>?  Or am I completely getting
confused here?

Looking around it seems some of these locations may have changed with
different /newer NB versions (see How to clear the cache in NetBeans
<https://stackoverflow.com/questions/8689780/how-to-clear-the-cache-in-netbeans/17238597#17238597>).
Is it possible some older cache location code still remains in some context?

>From what I can tell, the "Places" code is supposed to handle some
user/cache location cross platform logic.

In the Places.getCacheDirectory() code it seems to determine it relatie to
the user directory and append the var/cache subfolders like the following

File userdir = getUserDirectory();
        if (userdir != null) {
            return new File(new File(*userdir, "var"), "cache"*);
        }
        return new File(System.getProperty("java.io.tmpdir"), "nbcache");


So the getCacheDirectory() returns <user dir>/var/cache if a userdir exists
or else a temp/nbcache folder.  Is this an "old cache location" as well
needing to be updated or maybe has some OS specific criteria that has to be
addressed?

Is the "netbeans.user" directory supposed to point to a (1) <user
directory> or a (2) <user directory>/<version> folder?  Assume in most
cases it should be (2) but in cases =when trying to scan for all different
versions of user/cache directories like in the case of Janitor code, assume
that means it's scanning for different versions at (1) (which may imply
(2).parentDir() ) and finding each "version specific" (2) location.

in Janitor code...If the cache is at <netbeans.user>/<version>/var/cache
then the "cacheDir.getParent" would return "var" and not the "version" or
"cache" equivalent folder. If in a
%USERPROFILE%\AppData\Local\NetBeans\Cache\<version>
seems like it would return the "Cache" folder

File cacheDir = Places.getCacheDirectory();
        if (cacheDir != null) {
            ret = new File(cacheDir.getParentFile(), version);
            ret = ret.isDirectory() ? ret : null;
        }



Is there a netbeans version or platform specific criteria as to where the
"cache version" data gets stored that needs to be adjusted in a few places?

Is the usage of var/cache subfolder an artifact of older cache versioning
scheme (see above link) which has been replaced by something else in newer
NB versions?

Eric Bresie
ebre...@gmail.com


On Wed, Dec 28, 2022 at 6:10 PM Laszlo Kishalmi <laszlo.kisha...@gmail.com>
wrote:

> Well, the code is here:
> https://github.com/apache/netbeans/tree/master/platform/janitor
>
> I'd like if someone on Windows where this is reproducible could take a
> look. Maybe some file is locked there... I do not know. All I could do is
> to add a proper logging at
> https://github.com/apache/netbeans/blob/5f2e1382bc66d465a544ab358171c1810b57834f/platform/janitor/src/org/netbeans/modules/janitor/Janitor.java#L236
>
>
>
> On 12/28/22 09:25, Eric Bresie wrote:
>
> The only problem is when I do tell it to run the janitor it still does not
> run and it just keeps coming back and the folder remains.
>
> I think Laszlo mentioned maybe a permissions or some other issue
> previously.
>
> Where in the code base is this activity?
>
> Eric Bresie
> ebre...@gmail.com
>
>
> On Wed, Dec 14, 2022 at 1:10 PM Michael Bien <mbie...@gmail.com> wrote:
>
>> a flag per user dir or in general? Since you can uncheck "Run Janitor on
>> Startup" in the options to truly not be asked again unless you run it
>> manually :)
>>
>> its probably better to turn it off if you use a setup with multiple user
>> dirs for testing or other purposes (I have it off too).
>>
>> a per user dir flag would be essentially an ignore list which needs to
>> be exposed to the user somehow, e.g. via the options, so that it can be
>> reset etc - since its an edge case and there is a workaround for us, I
>> am not sure if its worth the trouble tbh.
>>
>> -mbien
>>
>> On 14.12.22 19:31, Tim Boudreau wrote:
>> > Since I keep two user dirs and cache dirs on purpose (because projects
>> that
>> > use jigsaw that depend on libraries that use Automatic-Module-Name on
>> their
>> > manifest get broken in the editor if you ever open the non-modular
>> project
>> > in the IDE), it could really use a “Don’t ask this again” checkbox.
>> >
>> > -Tim
>> >
>> > On Sun, Dec 11, 2022 at 10:39 AM Eric Bresie <ebre...@gmail.com> wrote:
>> >
>> >> I went ahead and created the following
>> >> https://github.com/apache/netbeans/issues/5069
>> >>
>> >> Eric Bresie
>> >> ebre...@gmail.com
>> >>
>> >>
>> >> On Sun, Dec 11, 2022 at 9:17 AM Eric Bresie <ebre...@gmail.com> wrote:
>> >>
>> >>> Hey Laszlo, did any updates around the orphaned "cache" get made?  I
>> see
>> >>> it showing up again in NB 16 so assume note.
>> >>>
>> >>> Should I create an issue on this?
>> >>>
>> >>> Eric Bresie
>> >>> ebre...@gmail.com
>> >>>
>> >>>
>> >>> On Mon, Jul 4, 2022 at 10:13 AM Eric Bresie <ebre...@gmail.com>
>> wrote:
>> >>>
>> >>>> So then a manual workaround is to change the permissions on
>> >>>> %USERPROFILE%\AppData\Local\Netbeans\Cache to be not just read only
>> and
>> >>>> then running it should fix it then?
>> >>>>
>> >>>> I like the idea of the enhancements...are further follow-up
>> enhancements
>> >>>> in work?
>> >>>>
>> >>>>
>> >>>> Eric Bresie
>> >>>> ebre...@gmail.com
>> >>>>
>> >>>>
>> >>>> On Fri, Jul 1, 2022 at 9:02 AM Laszlo Kishalmi <
>> >> laszlo.kisha...@gmail.com>
>> >>>> wrote:
>> >>>>
>> >>>>> Hi Eric,
>> >>>>>
>> >>>>> That was my "enhancement" for NB-14. The janitor module would detect
>> >>>>> abandoned cache directories.
>> >>>>>
>> >>>>> Usually there is an <userdir parent>/netbeans-14 and <cachedir
>> >>>>> parent>/netbeans-14. When the janitor encounters a directory in
>> >>>>> <cachedir parent> which has no pair in <userdir parent> then it
>> would
>> >>>>> think, that cache dir is abandoned and would offer it for removal.
>> >>>>>
>> >>>>> My primary intent was to clean up the leftover cache directories
>> when
>> >>>>> using the Snap distribution.
>> >>>>>
>> >>>>> On 7/1/22 06:35, Eric Bresie wrote:
>> >>>>>> Has anyone else had this problem?
>> >>>>>>
>> >>>>>> I've a number of versions (13 and 14) of Netbeans installed/used
>> >> with a
>> >>>>>> bunch of older versions since removed (i.e. 12.x and a mixture of
>> rc
>> >>>>> for
>> >>>>>> these).  When I startup I keep getting notifications that "Netbeans
>> >>>>> xx.xx
>> >>>>>> was last used xx days ago" with a "Remove unused data and cache
>> >>>>> directories
>> >>>>>> of xxx Free up xxx MB of space."  Sounds great so clicking on this
>> >> goes
>> >>>>>> away.  However, a little later, restart Netbeans and the same
>> >>>>> notifications
>> >>>>>> show up even after clicking the remove link.
>> >>>>>>
>> >>>>>> Eric Bresie
>> >>>>>> ebre...@gmail.com
>> >>>>>>
>> >>>>>
>> ---------------------------------------------------------------------
>> >>>>> To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
>> >>>>> For additional commands, e-mail: dev-h...@netbeans.apache.org
>> >>>>>
>> >>>>> For further information about the NetBeans mailing lists, visit:
>> >>>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
>> For additional commands, e-mail: dev-h...@netbeans.apache.org
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>>
>>
>>

Reply via email to