ion icon indicating copy to clipboard operation
ion copied to clipboard

Using `copyFiles` with a directory results in new zip file being uploaded even if the zip file contents haven't changed

Open Probotect0r opened this issue 4 months ago • 0 comments

I am using copyFiles with my function to copy the Prisma client into my functions' code packages:

  copyFiles: [
    { from: "node_modules/.prisma", to: "node_modules/.prisma" },
    {
      from: "node_modules/@prisma/client",
      to: "node_modules/@prisma/client",
    },
    {
      from: "node_modules/tracing.dist.js",
      to: "node_modules/tracing.dist.js",
    },
  ],

I noticed that a new version of my function gets uploaded to s3 even if the function's code or any of the copied files have not changed.

Using sst diff shows that hash of the zip seems to be changing, even though the zip file contents are exactly the same (same number of files, all the files are the exact same between the two zips).

This only seems to be happening when copying entire directories, and it is easier to produce with a directory that has a larger number of files or sub directories.

Inspecting the zip files with unzip -l, it is evident that the only difference is the ordering of the files within the zip file. If the ordering stays the same, the hash is the same.

There are a few outstanding issues in the archiverjs repository about this issue, with no solution as of yet: https://github.com/archiverjs/node-archiver/issues/383

Probotect0r avatar Oct 11 '24 15:10 Probotect0r