Skip to content

Raw File destination change with identical file basename causes file deletion

If a Raw File is mirrored into a location, then the destination is changed, there is a particular order of operations which mean the mirrored file is deleted entirely from main rather than being re-mirrored. Order of events as below.

Initial mirroring configuration:

kitchen/worktop:
  type: raw-file
  urls:
  - url: https://local.shop/fruit/banana.bunch
    destination: bowl/banana.bunch

This will mirror the file into bowl/banana.bunch/banana.bunch.

If the mirror config is then changed to the following:

kitchen/worktop:
  type: raw-file
  urls:
  - url: https://local.shop/fruit/banana.bunch
    destination: bowl

Then Lorry will remove the file at bowl/banana.bunch/banana.bunch but then fail to mirror the file to the new destination. This is due to a folder already existing at bowl/banana.bunch. If the folder is removed from Lorry's working directory, the file will be correctly mirrored again.

Unsure of the correct solution here, however:

  • Should Lorry clean up empty directories in its working dir before commit?
  • Should Lorry check the target location exists, and is a file?
  • If a sha256sum is specified, would this help?
  • If a sha256sum is specified and the target is actually a folder, what happens?
  • Should Lorry quietly ignore a destination basename if it is identical to the target filename?

This also opens an interesting question:

  • Should Lorry have deleted the file automatically?
  • Should Lorry throw an error on this occurrence and fail to Mirror?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information