Christian Couder <christian.cou...@gmail.com> writes:

> +static int can_delete_shared_index(const char *shared_index_path)
> +{
> +     struct stat st;
> +     unsigned long expiration;
> +
> +     /* Check timestamp */
> +     expiration = get_shared_index_expire_date();
> +     if (!expiration)
> +             return 0;
> +     if (stat(shared_index_path, &st))
> +             return error_errno(_("could not stat '%s"), shared_index_path);
> +     if (st.st_mtime > expiration)
> +             return 0;
> +
> +     return 1;
> +}
> +
> +static int clean_shared_index_files(const char *current_hex)
> +{
> +     struct dirent *de;
> +     DIR *dir = opendir(get_git_dir());
> +
> +     if (!dir)
> +             return error_errno(_("unable to open git dir: %s"), 
> get_git_dir());
> +
> +     while ((de = readdir(dir)) != NULL) {
> +             const char *sha1_hex;
> +             const char *shared_index_path;
> +             if (!skip_prefix(de->d_name, "sharedindex.", &sha1_hex))
> +                     continue;
> +             if (!strcmp(sha1_hex, current_hex))
> +                     continue;
> +             shared_index_path = git_path("%s", de->d_name);
> +             if (can_delete_shared_index(shared_index_path) > 0 &&

Is this "can" or "should"?  This sounds like the latter.

> +                 unlink(shared_index_path))
> +                     error_errno(_("unable to unlink: %s"), 
> shared_index_path);

This does not make the entire operation to fail (and I think the
behaviour you have here is preferrable--we just want to report
without failing the main operation).

But should it be reported as "error: unable to unlink"?  It may be
better to give this message as a warning.

Reply via email to