Skip to content

Deleting a file from the UI leaves the local cache copy behind and breaks re-upload #11

@Leonorus

Description

@Leonorus

Regression

This appears to have been introduced after #8, which started merging files from the local cache into /v1/list.

Problem

When a file is deleted from the Proxmox UI, it disappears from the UI, but the local cached file is still present under cache_dir. A later attempt to create or upload the same file name fails because Proxmox still sees the old file in the local datastore cache.

Example failure on recreate:

module.images.proxmox_download_file.image["talos"]: Creating...

Error: File already exists in the datastore, it was created outside of Terraform or is managed by another resource.

File already exists in the datastore: 'talos-v1.12.4-nocloud-amd64.iso',
error: error download file to datastore s3-iso: failed waiting for url download: task
"UPID:hv23:00237583:027C4C8F:69D60028:download:talos-v1.12.4-nocloud-amd64.iso:root@pam!gitlab:"
failed to complete with exit code: refusing to override existing file
'/var/cache/proxs3/s3-iso/template/iso/talos-v1.12.4-nocloud-amd64.iso'

Reproduction

  1. Create or upload an ISO/file through Proxmox/Terraform.
  2. Delete it from the Proxmox UI.
  3. Recreate the same file with the same name.
  4. The operation fails because the old local cache copy still exists.

Expected

Deleting a file from the UI should remove both:

  • the S3 object
  • the local cached copy in cache_dir

Actual

The object is gone from the UI/S3 view, but the local cache file remains on disk, and recreate attempts fail with refusing to override existing file.

Suspected root cause

The delete flow is not force-removing the physical file from the local cache directory in all cases. After #8, stale files in the cache became much more visible and impactful because cache contents are now merged into the storage view.

Proposed fix

In the deletion hook/path, force-delete the corresponding file from the local cache directory as well, not just the remote object or cache metadata/index entry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions