You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I posted this patch in a different issue a few weeks ago but it doesn't look like anyone saw it there so I figured I should create a new issue for it.
This patch fixes a problem reported in multiple issues (at least #3185, #3176 and #2004).
Micro puts state data in its configuration directory instead of a separate state data directory. This state data can grow very large which makes copying micro configuration to a new computer over a slow link much slower than expected. Since this state data can also include text, history and other information from previous files edited this could lead to an inadvertent disclosure of private or confidential information if the config directory is copied to a system where other people have access.
This patch separates micro's state files from micro's config files. With this patch state information is now stored in $MICRO_STATE_HOME so for example files that were previously searched for in $MICRO_CONFIG_HOME/buffers or $MICRO_CONFIG_HOME/backups are now searched for in $MICRO_STATE_HOME/buffers or $MICRO_STATE_HOME/backups respectively. If $MICRO_STATE_HOME does not exist $XDG_STATE_HOME/micro/ is used instead. If that doesn't exist either $HOME/.local/state/micro/ is used.
This patch simply adds a config.StateDir variable (alongside the existing config.ConfigDir) and uses it for state stuff. The patch will create the state directories if they don't already exist but does not touch the old location.
I don't do anything for migration because IMO it's not worth adding code that will sit in micro forever to address the minor one-time slight annoyance of history and cursor positions being reset. I think a small external migration script would be better for that (not included).
If anyone would like to test this without the hassle of building micro from source a statically linked binary for 64-bit Linux (x86_64) can be found here. It should work on any x86_64 Linux distribution. A statically linked binary for 64-bit Arm Linux (aarch64) can be found here for those of you using 64 bit ARM servers or Pis.
The text was updated successfully, but these errors were encountered:
The configuration directory can be set in command line arguments and checked as config.ConfigDir in plugins so micro.go and initlua.go in cmd/micro will have to be changed so that the same can be done. The man page in assets/packaging also has to be updated.
The code in config.InitConfigDir is duplicated so I think it would be better if a generic function is used with the configuration and state directory. There was a variable with underscore in name added in InitConfigDir but I do not think underscore is mixed in identifiers in Go code. err is usually reassigned if the variable was already defined in functions.
The directory environment variables are not usually set and the variables would have to be looked up even when trying to check options.md fast, so I think it is better if the default values are written in options.md. It may be better changing how the description of the state directory in options.md is written so that it does not seem repetitive.
Pull requests are used when sending changes and patch files are not usually used in projects in GitHub, so please consider changing the patch to one. I think this page will help.
I have not used and applied patch files before but there may be other people not familiar with them. I was able to apply it when running this command in directory with micro source code: patch -p1 < micro_state_dir.patch.txt
micro_state_dir.patch.txt
I posted this patch in a different issue a few weeks ago but it doesn't look like anyone saw it there so I figured I should create a new issue for it.
This patch fixes a problem reported in multiple issues (at least #3185, #3176 and #2004).
Micro puts state data in its configuration directory instead of a separate state data directory. This state data can grow very large which makes copying micro configuration to a new computer over a slow link much slower than expected. Since this state data can also include text, history and other information from previous files edited this could lead to an inadvertent disclosure of private or confidential information if the config directory is copied to a system where other people have access.
This patch separates micro's state files from micro's config files. With this patch state information is now stored in
$MICRO_STATE_HOME
so for example files that were previously searched for in$MICRO_CONFIG_HOME/buffers
or$MICRO_CONFIG_HOME/backups
are now searched for in$MICRO_STATE_HOME/buffers
or$MICRO_STATE_HOME/backups
respectively. If$MICRO_STATE_HOME
does not exist$XDG_STATE_HOME/micro/
is used instead. If that doesn't exist either$HOME/.local/state/micro/
is used.This patch simply adds a config.StateDir variable (alongside the existing config.ConfigDir) and uses it for state stuff. The patch will create the state directories if they don't already exist but does not touch the old location.
I don't do anything for migration because IMO it's not worth adding code that will sit in micro forever to address the minor one-time slight annoyance of history and cursor positions being reset. I think a small external migration script would be better for that (not included).
If anyone would like to test this without the hassle of building micro from source a statically linked binary for 64-bit Linux (x86_64) can be found here. It should work on any x86_64 Linux distribution. A statically linked binary for 64-bit Arm Linux (aarch64) can be found here for those of you using 64 bit ARM servers or Pis.
The text was updated successfully, but these errors were encountered: