file-conflict #2

Merged
taylor merged 1 commit from charlie/vpm:fix/file-conflict into main 2026-06-05 22:24:42 +01:00
Owner

I collapsed lines for readability where possible and followed the reference code @taylor pointed out in https://forge.dnsrail.org/vulpinelinux/vpm/issues/1 which was causing the issue, I've removed and rewrote the unnecessary nested checks so it only performs a single check in FILE_DB and iterates only over files in the package being installed instead.

Doing this to check if a file is owned by another rather than previous logic.

static int file_owned_by_other(const char *pkg, const char *path)
{
    FILE *fp = fopen(FILE_DB, "r");

    if (!fp)
        return 0;

    char owner[64];
    char fpath[PATH_MAX];

    while (fscanf(fp, "%63s %1023s", owner, fpath) == 2)
    {
        if (!strcmp(fpath, path) &&
            strcmp(owner, pkg))
        {
            fclose(fp);
            return 1;
        }
    }

    fclose(fp);
    return 0;
}

As you can see in the image you can now run:
sudo vpm install merk && sudo vpm install hello && sudo vpm list
Which will display both files successfully installed and usable.

img

I collapsed lines for readability where possible and followed the reference code @taylor pointed out in [https://forge.dnsrail.org/vulpinelinux/vpm/issues/1](https://forge.dnsrail.org/vulpinelinux/vpm/issues/1) which was causing the issue, I've removed and rewrote the unnecessary nested checks so it only performs a single check in `FILE_DB` and iterates only over files in the package being installed instead. Doing this to check if a file is owned by another rather than previous logic. ``` static int file_owned_by_other(const char *pkg, const char *path) { FILE *fp = fopen(FILE_DB, "r"); if (!fp) return 0; char owner[64]; char fpath[PATH_MAX]; while (fscanf(fp, "%63s %1023s", owner, fpath) == 2) { if (!strcmp(fpath, path) && strcmp(owner, pkg)) { fclose(fp); return 1; } } fclose(fp); return 0; } ``` As you can see in the image you can now run: `sudo vpm install merk && sudo vpm install hello && sudo vpm list` Which will display both files successfully installed and usable. ![img](https://cdn.dnsrail.org/uploads/1/media/screenshots/conflict_bug_resolved.png)
taylor merged commit 4623209744 into main 2026-06-05 22:24:42 +01:00
charlie locked and limited conversation to collaborators 2026-06-05 22:47:37 +01:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
vulpinelinux/vpm!2
No description provided.