Backup directory not changed when starting with -U...

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Backup directory not changed when starting with -U...

Felix Natter
Administrator
hello Devs,

there is a _small_ problem when changing the fpuserdir with -U:

I am starting with:
  /usr/bin/freeplane -U/home/felix/.config/freeplane_stable
--> fpuserdir=file:///home/felix/.config/freeplane_stable/1.3.x/

But prefs->backup directory is still:
  /home/felix/.freeplane/1.3.x/.backup

What do you think?

Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Volker Börchers
Administrator
Hi!

I think it should depend on the content of <fpuserdir>/auto.properties
(the fpuserdir that you set via -U). If it exists and if it contains a
setting for the backup directory then this should not be changed to
<fpuserdir>/.backup otherwise the latter should be used.

The other thing is the appended "1.3.x", but it's probably Ok.

Regards,
Volker

Am 01.08.2015 um 13:26 schrieb Felix Natter [via Freeplane Developer]:

> hello Devs,
>
> there is a _small_ problem when changing the fpuserdir with -U:
>
> I am starting with:
>    /usr/bin/freeplane -U/home/felix/.config/freeplane_stable
> --> fpuserdir=file:///home/felix/.config/freeplane_stable/1.3.x/
>
> But prefs->backup directory is still:
>    /home/felix/.freeplane/1.3.x/.backup
>
> What do you think?
>
> Best Regards,
> --
> Felix Natter
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/Backup-directory-not-changed-when-starting-with-U-tp735.html
>
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here
> <
> NAML
> <
http://freeplane-developer.996965.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
"Volker Börchers [via Freeplane Developer]"
<[hidden email]> writes:

> Hi!

hi Volker,

> I think it should depend on the content of <fpuserdir>/auto.properties
> (the fpuserdir that you set via -U). If it exists and if it contains a
> setting for the backup directory then this should not be changed to
> <fpuserdir>/.backup otherwise the latter should be used.
>
> The other thing is the appended "1.3.x", but it's probably Ok.

I looked at it with Dimitry: The Problem is that CommandLineParser
is executed after the single-backup-dir is setup and thus
the placeholder for the single-backup-dir is resolved before the
new fpuserdir property is set.

We propose a patch to change this (attached).

What do you think?
I will test this on linux tomorrow morning.

Best Regards,
--
Felix Natter

diff --git a/freeplane/src/main/java/org/freeplane/main/application/FreeplaneGUIStarter.java b/freeplane/src/main/java/org/freeplane/main/application/FreeplaneGUIStarter.java
index cb41afd..9b56bcb 100644
--- a/freeplane/src/main/java/org/freeplane/main/application/FreeplaneGUIStarter.java
+++ b/freeplane/src/main/java/org/freeplane/main/application/FreeplaneGUIStarter.java
@@ -126,8 +126,11 @@
  private static final String LOAD_LAST_MAPS = "load_last_maps";
  private static final String LOAD_LAST_MAP = "load_last_map";
  public static Boolean USE_RIBBONS_MENU;
- public FreeplaneGUIStarter() {
+ final private Options options;
+
+ public FreeplaneGUIStarter(String[] args) {
  super();
+ options = CommandLineParser.parse(args);
  final File userPreferencesFile = ApplicationResourceController.getUserPreferencesFile();
  firstRun = !userPreferencesFile.exists();
  new UserPropertiesUpdater().importOldProperties();
@@ -304,7 +307,6 @@
  new UserPropertiesUpdater().importOldDefaultStyle();
  EventQueue.invokeLater(new Runnable() {
  public void run() {
-    final Options options = CommandLineParser.parse(args);
  viewController.init(Controller.getCurrentController());
  splash.toBack();
  final Frame frame = viewController.getFrame();
diff --git a/freeplane/src/main/java/org/freeplane/main/application/FreeplaneMain.java b/freeplane/src/main/java/org/freeplane/main/application/FreeplaneMain.java
index 5b09a96..d074ee3 100644
--- a/freeplane/src/main/java/org/freeplane/main/application/FreeplaneMain.java
+++ b/freeplane/src/main/java/org/freeplane/main/application/FreeplaneMain.java
@@ -45,7 +45,7 @@
         if(oldHandler != null)
             newHandler = oldHandler + '|' + newHandler;
         System.setProperty("java.protocol.handler.pkgs", newHandler);
- final FreeplaneStarter starter = new FreeplaneGUIStarter();
+ final FreeplaneStarter starter = new FreeplaneGUIStarter(args);
  starter.run(args);
  }
 }
diff --git a/freeplane/src/main/java/org/freeplane/main/osgi/ActivatorImpl.java b/freeplane/src/main/java/org/freeplane/main/osgi/ActivatorImpl.java
index 8cfb8cd..605b538 100644
--- a/freeplane/src/main/java/org/freeplane/main/osgi/ActivatorImpl.java
+++ b/freeplane/src/main/java/org/freeplane/main/osgi/ActivatorImpl.java
@@ -245,7 +245,7 @@
  if(Boolean.getBoolean(HEADLESS_RUN_PROPERTY_NAME))
  return new FreeplaneHeadlessStarter();
  else
- return new FreeplaneGUIStarter();
+ return new FreeplaneGUIStarter(getCallParameters());
     }
 
     private void registerClasspathUrlHandler(final BundleContext context) {
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
hello Volker,
hello Dimitry,

I just tried the patch, it seems to work: When I start with -U/tmp/foo, I get
backup-directory=/tmp/foo/1.4.x/.backup.

However:

(1) the list of loaded mindmaps  was not reset

(2) I get the command line output
-U/tmp/foo
twice. With 1.3.12, I see this only once.

I will look into this.

Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
hello Volker,
hello Dimitry,

can you tell me where the -U output comes from? I couldn't find it ini the sources.

Created Framework: org.knopflerfish.framework, version=7.1.2.
-U/tmp/foo2
-U/tmp/foo2
Installed: reference:file:/home/felix/git2/freeplane4/BUILD/plugins/org.freeplane.plugin.latex (id#2)

Also, I'd like to debug this (why the list of loaded mindmaps is not reset), but when using the following
"Program arguments" in eclipse, the -U option is not triggered:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -console -U/tmp/foo2

Any ideas? Do I have to use remote debugging with freeplane.sh?

Cheers and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Volker Börchers
Administrator
Hi Felix,

the relevant code is in CommandLineParser.

Best regards,
Volker

Am 29.08.2015 um 12:47 schrieb Felix Natter [via Freeplane Developer]:

> hello Volker,
> hello Dimitry,
>
> can you tell me where the -U output comes from? I couldn't find it ini
> the sources.
>
> Created Framework: org.knopflerfish.framework, version=7.1.2.
> -U/tmp/foo2
> -U/tmp/foo2
> Installed:
> reference:file:/home/felix/git2/freeplane4/BUILD/plugins/org.freeplane.plugin.latex
> (id#2)
>
> Also, I'd like to debug this (why the list of loaded mindmaps is not
> reset), but when using the following
> "Program arguments" in eclipse, the -U option is not triggered:
>
> -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
> -console -U/tmp/foo2
>
> Any ideas? Do I have to use remote debugging with freeplane.sh?
>
> Cheers and Best Regards,
> Felix
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/Backup-directory-not-changed-when-starting-with-U-tp735p744.html
>
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here
> <
> NAML
> <
http://freeplane-developer.996965.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
"Volker Börchers [via Freeplane Developer]"
<[hidden email]> writes:

> Hi Felix,

hello Volker,

> the relevant code is in CommandLineParser.

Ok, found it. Command line parameters are parsed in FreeplaneGUIStarter
and SingleInstanceManager, which is OK because it doesn't modify
anything.

What is not okay (and this is the root cause for the list of loaded
mindmaps not being reset) is that there is no auto.properties in
the prefs dir given by -U:

// prefs dir from -U/home/felix/.config/freeplane_stable:
felix@bitburger:~/.config/freeplane_stable/1.3.x$ ls -lh
insgesamt 44K
drwxr-xr-x 3 felix felix 4,0K Jun 14 19:37 addons
-rw-r--r-- 1 felix felix   21 Aug 29 18:26 auto.mmfilter
-rw-r--r-- 1 felix felix 1,7K Mai  1 13:31 formats.xml
drwxr-xr-x 2 felix felix 4,0K Mai  1 13:31 icons
drwxr-xr-x 2 felix felix 4,0K Mai  1 13:31 lib
drwxr-xr-x 2 felix felix 4,0K Aug 29 18:26 logs
drwxr-xr-x 3 felix felix 4,0K Jun 14 19:37 resources
-rw-r--r-- 1 felix felix 5,9K Jun 23 19:51 scanner.xml
drwxr-xr-x 2 felix felix 4,0K Mai  1 13:31 scripts
drwxr-xr-x 2 felix felix 4,0K Mai  1 13:31 templates

// default prefs dir:
felix@bitburger:~/.config/freeplane/1.3.x$ ls -lh
insgesamt 80K
drwxr-xr-x 6 felix felix 4,0K Aug 10  2014 addons
-rw-r--r-- 1 felix felix 1,3K Jul 11 21:28 auto.mmfilter
-rw-r--r-- 1 felix felix 1,5K Dez 28  2013 _auto.mmfilter
-rw-r--r-- 1 felix felix  18K Aug 29 18:26 auto.properties
drwxr-xr-x 4 felix felix 4,0K Aug 10  2014 doc
-rw-r--r-- 1 felix felix 1,7K Dez 28  2013 formats.xml
drwxr-xr-x 2 felix felix 4,0K Mär 24  2014 icons
drwxr-xr-x 4 felix felix 4,0K Jun 24  2014 lib
drwxr-xr-x 2 felix felix 4,0K Jul 11 21:28 logs
drwxr-xr-x 3 felix felix 4,0K Aug 10  2014 resources
-rw-r--r-- 1 felix felix 6,5K Dez 12  2014 scanner.xml
drwxr-xr-x 2 felix felix 4,0K Jan 29  2014 scripts
drwxr-xr-x 3 felix felix 4,0K Mär 24  2014 templates
drwxr-xr-x 3 felix felix 4,0K Sep 13  2014 users
drwxr-xr-x 2 felix felix 4,0K Jul 17  2014 xslt

So I _guess_ it reads+writes to the default prefs dir :-(

I will look into this, but any ideas are appreciated.

Thanks and Best Regards,
--
Felix Natter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
hi Devs,

I have fixed this by also setting old_userfpdir, so that old settings are not imported when -U is used:
https://github.com/freeplane/freeplane/commits/fixUoption

If you agree then I will integrate this soon.

Also, @Volker: In CommandLineParser.parse() we use code like this:
else if (args.length >= i)
      result.addMenuItemToExecute(args[++i]);

So we access i+1 if length>=i. I think this should be:
else if (args.length > i + 1)
      result.addMenuItemToExecute(args[++i]);

Do you agree if I change this?

Cheers and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
@Volker: I fixed the small array length check issue because I wanted
to finish this up. Should be correct ;-)

Cheers and Best Regards,
Felix
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Volker Börchers
Administrator
In reply to this post by Felix Natter
Hi Felix,

Am 30.08.2015 um 16:40 schrieb Felix Natter [via Freeplane Developer]:

> Also, @Volker: In CommandLineParser.parse() we use code like this:
[...]
> So we access i+1 if length>=i. I think this should be:
> else if (args.length > i + 1)
>        result.addMenuItemToExecute(args[++i]);
>
> Do you agree if I change this?

As you have debugged and tested the code now you are way more competent
to answer the question than me as I wrote that years ago :-)

Regards,
Volker
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Backup directory not changed when starting with -U...

Felix Natter
Administrator
In reply to this post by Felix Natter
"Felix Natter [via Freeplane Developer]"
<[hidden email]> writes:

> @Volker: I fixed the small array length check issue because I wanted
> to finish this up. Should be correct ;-)

Branch merged.

Best Regards,
--
Felix Natter
Loading...