Skip to content

[FEATURE REQUEST] Prevent cache upload (to S3) if cache file/folder is empty/non-existent #62

@ghost

Description

In one of my CI jobs, I noticed that the plugin was able to upload an empty/non-existent file/folder to S3.

[2023-06-27T23:17:34Z] [typescript-cache] - 🔍 Locating cache:  my_project/some_cacheable_folder
[2023-06-27T23:17:34Z] tar: my_project/some_cacheable_folder: Warning: Cannot stat: No such file or directory
upload: ./cacheable_folder-v1-checksum123.tar.gz to s3://bucket/caches/cacheable_folder-v1-checksum123.tar.gz

This has consequences for CI jobs that have the same cache key because those jobs end up downloading and using an empty cache. For example, this might lead to slower build times (e.g. imagine a bundler like Webpack trying to read from an empty cache which causes bundling time to be slower compared to not using a cache).

Ideally the build would complete but not upload the cache if the cache file is not found. Maybe we can add an option to do this.

e.g.

nienbo/cache#v2.4.14:
    id: node-modules-cache
    backend: s3
    ...
    paths:
      - "my_project/some_cacheable_folder"
    upload: 
      - "always"(default) | "skip-if-tarfile-empty" | "skip"

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions