dav/sync.c

changeset 528
4c9c8c017d52
parent 527
d0e37224eba1
child 529
dc3f82b04733
equal deleted inserted replaced
527:d0e37224eba1 528:4c9c8c017d52
1577 fprintf(stderr, "Command ''restore'' is not allowed for this sync dir\n"); 1577 fprintf(stderr, "Command ''restore'' is not allowed for this sync dir\n");
1578 print_allowed_cmds(dir); 1578 print_allowed_cmds(dir);
1579 return -1; 1579 return -1;
1580 } 1580 }
1581 1581
1582 DavBool restore_modified = cmd_getoption(a, "restore-modified") ? 1 : 0;
1583 DavBool restore_removed = cmd_getoption(a, "restore-removed") ? 1 : 0;
1584 if(!restore_modified && !restore_removed) {
1585 restore_modified = 1;
1586 restore_removed = 1;
1587 }
1588
1582 SyncDatabase *db = load_db(dir->database); 1589 SyncDatabase *db = load_db(dir->database);
1583 if(!db) { 1590 if(!db) {
1584 fprintf(stderr, "Cannot load database file: %s\n", dir->database); 1591 fprintf(stderr, "Cannot load database file: %s\n", dir->database);
1585 return -1; 1592 return -1;
1586 } 1593 }
1600 1607
1601 char *file_path = util_concat_path(dir->path, resource->path); 1608 char *file_path = util_concat_path(dir->path, resource->path);
1602 SYS_STAT s; 1609 SYS_STAT s;
1603 if(sys_stat(file_path, &s)) { 1610 if(sys_stat(file_path, &s)) {
1604 if(errno == ENOENT) { 1611 if(errno == ENOENT) {
1605 deleted = ucx_list_prepend(deleted, resource); 1612 if(restore_removed) {
1613 deleted = ucx_list_prepend(deleted, resource);
1614 }
1606 } else { 1615 } else {
1607 fprintf(stderr, "Cannot stat file: %s\n", file_path); 1616 fprintf(stderr, "Cannot stat file: %s\n", file_path);
1608 perror(""); 1617 perror("");
1609 } 1618 }
1610 } else if(!resource->isdirectory && !S_ISDIR(s.st_mode)) { 1619 } else if(!resource->isdirectory && !S_ISDIR(s.st_mode)) {
1611 if(resource->last_modified != s.st_mtime || resource->size != s.st_size) { 1620 if(resource->last_modified != s.st_mtime || resource->size != s.st_size) {
1612 modified = ucx_list_prepend(modified, resource); 1621 if(restore_modified) {
1622 modified = ucx_list_prepend(modified, resource);
1623 }
1613 } 1624 }
1614 } 1625 }
1615 1626
1616 free(file_path); 1627 free(file_path);
1617 } 1628 }

mercurial