[Commits] r659 - trunk/daemon/src
new-commit at lists.openvcp.org
new-commit at lists.openvcp.org
Sat May 2 17:22:35 UTC 2009
Author: cryptronic
Date: 2009-05-02 17:22:35 +0000 (Sat, 02 May 2009)
New Revision: 659
Modified:
trunk/daemon/src/request.c
trunk/daemon/src/userbackup.c
trunk/daemon/src/userbackup.h
Log:
Bug fixes for userbackups
Modified: trunk/daemon/src/request.c
===================================================================
--- trunk/daemon/src/request.c 2009-03-10 18:44:29 UTC (rev 658)
+++ trunk/daemon/src/request.c 2009-05-02 17:22:35 UTC (rev 659)
@@ -81,6 +81,7 @@
{ "create_userbackups", { NULL }, "", create_userbackups },
{ "restore_userbackups", { NULL }, "", restore_userbackups },
{ "delete_userbackups", { NULL }, "", delete_userbackups },
+ { "refresh_userbackups", { NULL }, "", refresh_userbackups },
{ NULL, {NULL}, NULL, NULL }
};
Modified: trunk/daemon/src/userbackup.c
===================================================================
--- trunk/daemon/src/userbackup.c 2009-03-10 18:44:29 UTC (rev 658)
+++ trunk/daemon/src/userbackup.c 2009-05-02 17:22:35 UTC (rev 659)
@@ -63,7 +63,7 @@
if(dir_entry->d_name[0] != '.')
{
- if(strspn(dir_entry->d_name, name) == strlen(name))
+ if(strstr(dir_entry->d_name, name) != NULL)
ovcp_response_add_string(response, dir_entry->d_name);
}
@@ -127,7 +127,11 @@
userbackupdir = concat(global_settings.userbackup_dir, "/", backupname, NULL);
homedir = concat(global_settings.root_dir, "/", name, NULL);
- execb_cmd("cp", "cp", "-a", homedir, userbackupdir, NULL);
+ if(execb_cmd("rsync", "rsync", "-a", homedir, userbackupdir, NULL) != 0)
+ {
+ execb_cmd("rm", "rm", "-rf", userbackupdir, NULL);
+ return ovcp_response_error(OVCP_ERROR_BACKUPFAIL, OVCP_ERROR_BACKUPFAIL_DESC);
+ }
response = ovcp_response_new();
@@ -209,6 +213,56 @@
}
+
+struct ovcp_response_st *refresh_userbackups(struct ovcp_request_st *request)
+{
+ struct ovcp_data_st *arg0, *arg1;
+ struct ovcp_response_st *response;
+
+ char *name, *homedir, *userbackupdir, *backupname;
+ int ret=0;
+
+ arg0 = ovcp_request_get_arg(request, 0);
+ name = (char *)ovcp_data_get(arg0);
+
+ arg1 = ovcp_request_get_arg(request, 1);
+ backupname = (char *)ovcp_data_get(arg1);
+
+ userbackupdir = concat(global_settings.userbackup_dir, "/", backupname, NULL);
+ homedir = concat(global_settings.root_dir, "/", name, NULL);
+
+ response = ovcp_response_new();
+
+ if(dir_exist(homedir) && dir_exist(userbackupdir))
+ {
+
+ if(dir_exist(homedir))
+ return ovcp_response_error(OVCP_ERROR_BACKUPFAIL, OVCP_ERROR_BACKUPFAIL_DESC);
+
+ ret = execb_cmd("rsync", "rsync", "-a", userbackupdir, homedir, NULL);
+
+ if(ret != 0)
+ {
+ return ovcp_response_error(OVCP_ERROR_BACKUPFAIL, OVCP_ERROR_BACKUPFAIL_DESC);
+ }
+ else
+ {
+ ovcp_response_add_string(response, "Success");
+ }
+ }
+ free(backupname);
+ free(userbackupdir);
+ free(homedir);
+ return response;
+
+}
+
+
+
+
+
+
+
struct ovcp_response_st *delete_userbackups(struct ovcp_request_st *request)
{
struct ovcp_data_st *arg0;
Modified: trunk/daemon/src/userbackup.h
===================================================================
--- trunk/daemon/src/userbackup.h 2009-03-10 18:44:29 UTC (rev 658)
+++ trunk/daemon/src/userbackup.h 2009-05-02 17:22:35 UTC (rev 659)
@@ -24,6 +24,7 @@
struct ovcp_response_st *get_userbackups(struct ovcp_request_st *request);
struct ovcp_response_st *create_userbackups(struct ovcp_request_st *request);
struct ovcp_response_st *restore_userbackups(struct ovcp_request_st *request);
+ struct ovcp_response_st *refresh_userbackups(struct ovcp_request_st *request);
struct ovcp_response_st *delete_userbackups(struct ovcp_request_st *request);
#endif
More information about the Commits
mailing list