diff options
author | Yorhel <git@yorhel.nl> | 2013-06-09 10:29:46 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2013-06-09 10:29:46 +0200 |
commit | d39772718e4129ce79d4ea0b52f401442dced157 (patch) | |
tree | 522da96a3f97247db399244ff2224a2b4b745e16 | |
parent | a96bbfa5c3cfd2b1e5a4abe13e7940fa9d7e0144 (diff) |
share/scan: Use casestr_cmp() for removing duplicate files
-rw-r--r-- | src/share/scan.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/share/scan.c b/src/share/scan.c index c39d5af..4733358 100644 --- a/src/share/scan.c +++ b/src/share/scan.c @@ -183,7 +183,7 @@ static share_flv_t share_scan_thread_readdir(share_scan_work_t *w) { /* Remove items with the same (casefolded) name. In order to avoid that a * different item is chosen at each scan, the item to be removed is decided by - * a memcmp() on the casestr data (Which is almost always different for + * a casestr_cmp() on the casestr data (Which is almost always different for * different files, but reality sucks when, due to charset conversion, two * files map to exactly the same name. Properly handling that case may * complicate the code more than I'd like, so let's just accept some "random" @@ -195,9 +195,7 @@ static void share_scan_thread_rmdupes(share_scan_work_t *w, share_flv_t *lst) { char *as = share_fl_name(lst->a[i-1]); char *bs = share_fl_name(lst->a[i]); if(strcmp(as, bs) == 0) { - size_t al = casestr_len(as); - size_t bl = casestr_len(bs); - size_t rem = al < bl ? i-1 : al > bl ? i : memcmp(as, bs, al) > 0 ? i-1 : i; + size_t rem = casestr_cmp(as, bs) < 0 ? i : i-1; yinfo("Multiple files in '%s' casefold to '%s', only one will be shared", w->fspath, as); free(lst->a[rem]); vec_remove_order(*lst, rem); @@ -291,7 +289,7 @@ static void share_scan_merge(share_fl_t *dst, share_flv_t *lst) { /* lf == df, the item is in both dst and lst. Check for differences. */ if(lf->size != df->size /* Also catches lf->isdir != df->isdir */ || (lf->size != UINT64_MAX && (lf->lastmod != df->lastmod || lf->pathid != lf->pathid)) - || !casestr_eq(share_fl_name(lf), share_fl_name(df))) { + || casestr_cmp(share_fl_name(lf), share_fl_name(df)) != 0) { share_scan_merge_del(df); share_scan_merge_new(dst, lf); dst->sub.a[di] = lf; |