dav/sync.c

changeset 506
ceed7714846a
parent 505
481802342fdf
child 510
d6e801f97e7a
equal deleted inserted replaced
505:481802342fdf 506:ceed7714846a
1189 UcxList *resources = local_scan(dir, db); 1189 UcxList *resources = local_scan(dir, db);
1190 UcxMap *resources_map = ucx_map_new(ucx_list_size(resources)+16); 1190 UcxMap *resources_map = ucx_map_new(ucx_list_size(resources)+16);
1191 1191
1192 UCX_FOREACH(elm, resources) { 1192 UCX_FOREACH(elm, resources) {
1193 LocalResource *local_res = elm->data; 1193 LocalResource *local_res = elm->data;
1194
1195 // ignore all files, that are excluded by a static filter (sync.xml) 1194 // ignore all files, that are excluded by a static filter (sync.xml)
1196 1195
1197 // static include/exclude filter 1196 // static include/exclude filter
1198 if(res_matches_filter(dir, local_res->path+1)) { 1197 if(res_matches_filter(dir, local_res->path+1)) {
1199 continue; 1198 continue;
1243 } 1242 }
1244 1243
1245 // find all deleted files and cleanup the database 1244 // find all deleted files and cleanup the database
1246 UcxMapIterator i = ucx_map_iterator(db->resources); 1245 UcxMapIterator i = ucx_map_iterator(db->resources);
1247 LocalResource *local; 1246 LocalResource *local;
1248 UCX_MAP_FOREACH(key, local, i) { 1247 UcxList *removed_res = NULL;
1248 UCX_MAP_FOREACH(key, local, i) {
1249 // all filtered files should be removed from the database 1249 // all filtered files should be removed from the database
1250 if(res_matches_filter(dir, local->path+1)) { 1250 if(res_matches_filter(dir, local->path+1)) {
1251 ucx_map_cstr_remove(db->resources, local->path); 1251 ucx_map_cstr_remove(db->resources, local->path);
1252 continue; 1252 continue;
1253 } 1253 }
1264 // in the filesystem anymore. This means the file was deleted 1264 // in the filesystem anymore. This means the file was deleted
1265 // and should be deleted on server 1265 // and should be deleted on server
1266 if(!archive) { 1266 if(!archive) {
1267 ls_delete = ucx_list_append(ls_delete, local); 1267 ls_delete = ucx_list_append(ls_delete, local);
1268 } else { 1268 } else {
1269 ucx_map_cstr_remove(db->resources, local->path); 1269 removed_res = ucx_list_prepend(removed_res, local);
1270 } 1270 }
1271 } 1271 }
1272 }
1273 UCX_FOREACH(elm, removed_res) {
1274 LocalResource *local = elm->data;
1275 ucx_map_cstr_remove(db->resources, local->path);
1272 } 1276 }
1273 1277
1274 ls_delete = ucx_list_sort(ls_delete, (cmp_func)resource_pathlen_cmp, NULL); 1278 ls_delete = ucx_list_sort(ls_delete, (cmp_func)resource_pathlen_cmp, NULL);
1275 1279
1276 // 1280 //

mercurial