nonissue / dotfiles

My dotfiles for macOS/ubuntu (tmux/nvim/fish/glances/iterm/bat/etc)

Home Page:https://nonissue.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(fish) function that checks that files in folder X exist in folder Y

nonissue opened this issue · comments

For example, say you have a daily job to upload new local files to a remote storage device. In this scenario, once the files are successfully uploaded to the remote storage device (that is also setup as a mounted volume), we want to remove them from the local device to free up space. This function would accept a directory /path/to/dirX and verify all files contained within dirX are in /path/different/branch/of/file/tree/dirY.

Not sure the best to accurate compare the dirX/fileA with dirY/fileA though. md5 seems really slow on larger files, and we aren't OVERLY concerned about accuracy. Maybe just verify the file size is the same in bytes?

Interestingly, running du -s on a known good file located both locally and remotely reveals slightly different results...

Maybe drop the last N digits?

Something like...
find /mnt/media/local/tv/ type f -exec du -s {} \; | string sub -l 5

Other things to resolve:

  • Skip files smaller than Nkb
  • Get both the file name and file size in one pass.