Skip to content
Snippets Groups Projects
Commit 8383c776 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

Make `update@` as a reserved prefix for snapshot name

parent e2f56551
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,8 @@ This subcommand make a snapshot called *named* containing a verbatim copy of the ...@@ -76,6 +76,8 @@ This subcommand make a snapshot called *named* containing a verbatim copy of the
`%%livedir%%`, `%%system_log%%` and `$HOME/%%user_log%%` for regular users are not taken into account. `%%livedir%%`, `%%system_log%%` and `$HOME/%%user_log%%` for regular users are not taken into account.
The prefix `update@` is reserved for snapshot names used in automatic upgrade processes. Please consider to choose a different prefix for your personal. snapshot names.
#### Options #### Options
- **-h**: prints this help. - **-h**: prints this help.
......
...@@ -152,6 +152,9 @@ int ssexec_snapshot_create(int argc, char const *const *argv, ssexec_t *info) ...@@ -152,6 +152,9 @@ int ssexec_snapshot_create(int argc, char const *const *argv, ssexec_t *info)
snapname = *argv ; snapname = *argv ;
if (!str_start_with(snapname, "update@"))
log_die(LOG_EXIT_USER, "update@ is a reserved prefix for snapshot names -- please select a different one") ;
auto_strings(snapdir.s, info->base.s, SS_SNAPSHOT + 1) ; auto_strings(snapdir.s, info->base.s, SS_SNAPSHOT + 1) ;
len = info->base.len + (SS_SNAPSHOT_LEN - 1) ; len = info->base.len + (SS_SNAPSHOT_LEN - 1) ;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <oblibs/string.h> #include <oblibs/string.h>
#include <oblibs/stack.h> #include <oblibs/stack.h>
#include <oblibs/sastr.h> #include <oblibs/sastr.h>
#include <oblibs/directory.h>
#include <skalibs/sgetopt.h> #include <skalibs/sgetopt.h>
#include <skalibs/djbunix.h> #include <skalibs/djbunix.h>
...@@ -102,6 +103,17 @@ int ssexec_snapshot_restore(int argc, char const *const *argv, ssexec_t *info) ...@@ -102,6 +103,17 @@ int ssexec_snapshot_restore(int argc, char const *const *argv, ssexec_t *info)
log_dieusys(LOG_EXIT_SYS, "copy: ", src.s," to: ", dst.s) ; log_dieusys(LOG_EXIT_SYS, "copy: ", src.s," to: ", dst.s) ;
} }
auto_strings(src.s, snapdir.s, "/", SS_SYSTEM, "/.version") ;
/** remove .version file if it doesn't exist at snapshot dir.
* Typically version under 0.8.0.0 do not have this file.*/
if (access(src.s, F_OK) < 0) {
auto_strings(src.s, info->base.s, SS_SYSTEM, "/.version") ;
if (!dir_rm_rf(src.s))
log_warnusys("remove file: ", src.s) ;
}
log_info("Successfully restored snapshot: ", snapname) ; log_info("Successfully restored snapshot: ", snapname) ;
return 0 ; return 0 ;
......
...@@ -610,12 +610,12 @@ static void migrate_create_snap_0721(ssexec_t *info) ...@@ -610,12 +610,12 @@ static void migrate_create_snap_0721(ssexec_t *info)
info->usage = usage_snapshot_create ; info->usage = usage_snapshot_create ;
newargv[m++] = "snapshot" ; newargv[m++] = "snapshot" ;
newargv[m++] = "0.7.2.1" ; newargv[m++] = "update@0.7.2.1" ;
newargv[m] = 0 ; newargv[m] = 0 ;
PROG = "snapshot" ; PROG = "snapshot" ;
if (ssexec_snapshot_create(m, newargv, info)) if (ssexec_snapshot_create(m, newargv, info))
log_dieu(LOG_EXIT_SYS, "create snapshot: ", "0.7.2.1") ; log_dieu(LOG_EXIT_SYS, "create snapshot update@0.7.2.1") ;
PROG = prog ; PROG = prog ;
info->help = help ; info->help = help ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment