aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-09-11 14:39:24 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-09-11 14:39:24 +0200
commit37de0cc7b0eeeefcc25173913faaefa2a7673d2c (patch)
tree33a216d1c211e00aff2035e929d304768e5064e1 /src/qt
parent7809edab2aab5701f7be3f278b10e030e944477e (diff)
downloadOFQT-37de0cc7b0eeeefcc25173913faaefa2a7673d2c.tar.gz
OFQT-37de0cc7b0eeeefcc25173913faaefa2a7673d2c.zip
rename force update to verify, reorder updates, return rename retval
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/workers.cpp56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/qt/workers.cpp b/src/qt/workers.cpp
index a54509f..1642813 100644
--- a/src/qt/workers.cpp
+++ b/src/qt/workers.cpp
@@ -201,32 +201,40 @@ int Worker::update_setup(int local_rev, int remote_rev)
{
struct file_info* file = &rev->files[i];
- progress = (int)(((i * 100) + 1) / rev->file_count);
- emit resultReady(RESULT_UPDATE_TEXT);
+ if (file->type != TYPE_DELETE) continue;
+ size_t len = strlen(of_dir) + strlen(OS_PATH_SEP) + strlen(file->path) + 1;
+ char* buf = (char*)malloc(len);
+ snprintf(buf, len, "%s%s%s", of_dir, OS_PATH_SEP, file->path);
+ if (isFile(buf) && remove(buf))
+ {
+ printf("\nFailed to delete %s\n", file->path);
+ }
+ free(buf);
+ }
+
+ for (size_t i = 0; i < rev->file_count && do_work; ++i)
+ {
+ struct file_info* file = &rev->files[i];
+
+ if (file->type != TYPE_MKDIR) continue;
+ size_t len = strlen(of_dir) + strlen(OS_PATH_SEP) + strlen(file->path) + 1;
+ char* buf = (char*)malloc(len);
+ if (!isDir(buf) && makeDir(buf))
+ {
+ printf("\nFailed to create %s\n", file->path);
+ }
+ free(buf);
+ }
+
+ for (size_t i = 0; i < rev->file_count; ++i)
+ {
+ struct file_info* file = &rev->files[i];
- switch (file->type)
+ if (file->type != TYPE_WRITE) continue;
+ fprintf(stderr, "\rInstalling %zu/%zu (%s)", i+1, rev->file_count, file->object);
+ if (applyObject(of_dir, file))
{
- case TYPE_WRITE:
- case TYPE_MKDIR:
- {
- retval += applyObject(of_dir, file);
- }
- break;
-
- case TYPE_DELETE:
- {
- size_t len = strlen(of_dir) + strlen(OS_PATH_SEP) + strlen(file->path) + 1;
- char* buf = (char*)malloc(len);
- snprintf(buf, len, "%s%s%s", of_dir, OS_PATH_SEP, file->path);
- if (isFile(buf))
- retval += remove(buf);
- free(buf);
- }
- break;
-
- default:
- assert(0);
- break;
+ printf("\nFailed to write %s\n", file->path);
}
}