diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2023-03-31 00:50:54 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2023-03-31 00:50:54 +0200 |
commit | 045e16665a55e2b7b6dc2e953c91f2125f61e083 (patch) | |
tree | 13c1ec30513fc780b6e04469740e784b907428c8 /src/cli | |
parent | 55b916972339f95b2cd7c13c178e43c12f71c147 (diff) | |
download | OFQT-045e16665a55e2b7b6dc2e953c91f2125f61e083.tar.gz OFQT-045e16665a55e2b7b6dc2e953c91f2125f61e083.zip |
check for write failure and notify accordingly
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/updater.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cli/updater.c b/src/cli/updater.c index bdccaca..fd6df1b 100644 --- a/src/cli/updater.c +++ b/src/cli/updater.c @@ -93,6 +93,7 @@ void update_setup(char* of_dir, char* remote, int local_rev, int remote_rev) snprintf(buf, len, "%s%s%s", of_dir, OS_PATH_SEP, file->path); if (isFile(buf) && remove(buf)) { + // deletion failure is fine and can simple be ignored. fprintf(stderr, "\rFailed to delete %s\n", file->path); } free(buf); @@ -114,6 +115,9 @@ void update_setup(char* of_dir, char* remote, int local_rev, int remote_rev) free(buf); } + + char write_failure = 0; + for (size_t i = 0; i < rev->file_count; ++i) { struct file_info* file = &rev->files[i]; @@ -122,15 +126,22 @@ void update_setup(char* of_dir, char* remote, int local_rev, int remote_rev) fprintf(stderr, "\rInstalling %zu/%zu (%s)", i+1, rev->file_count, file->object); if (applyObject(of_dir, file)) { + // failing to write an object usually means something is wrong with the path or object fprintf(stderr, "\nFailed to write %s\n", file->path); + write_failure = 1; } } - removeObjects(of_dir); setLocalRemote(of_dir, remote); - setLocalRevision(of_dir, remote_rev); + if (!write_failure) + { + removeObjects(of_dir); + setLocalRevision(of_dir, remote_rev); + fprintf(stderr, "\nUpdated OpenFortress\n"); + } + else + fprintf(stderr, "\nSomething went wrong during the upgrade\nThe Revisionw as installed as is, you can try updating again to fix it.\n"); - fprintf(stderr, "\nUpdated OpenFortress\n"); freeRevision(rev); } } |