Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vach preserve file/dir metadata? tar drop-in replacement CLI #76

Open
omac777 opened this issue Mar 11, 2022 · 11 comments
Open

vach preserve file/dir metadata? tar drop-in replacement CLI #76

omac777 opened this issue Mar 11, 2022 · 11 comments

Comments

@omac777
Copy link

omac777 commented Mar 11, 2022

The current defacto capability standards out there for preserving file metadata(user/group ownership, datetime of creation, modification and such) and directory metadata are tar and rsync.

I would recommend vach:

  • match tar's/rsync's capability standard for preserving file metadata and directory metadata.
    before vach can be considered as a valid replacement. Does vach preserve the metadata?
  • provide an instant drop-in replacement for tar in the form of a compatible CLI accepting the usual tar CLI convention and behaviour. It would certainly help ease evaluating/adopting vach.
    i.e.
tar cvf blah.tar blah/
tar xvf blah.tar -C /testdest/blah/
vach cvf blah.vach blah/
vach xvf blah.vach -C /testdest/blah/
@sokorototo
Copy link
Collaborator

That is a good point, at the moment vach only stores content and discards file metadata. Implementing such a feature will require that the spec change or we implement it in a non-destructive way. We will get to working on a non-destructive solution first

@sokorototo
Copy link
Collaborator

sokorototo commented Mar 12, 2022

After some research, best we can do is add timestamps to vach. Restoring file permissions requires root privileges and adding support for root privileges will blow our complexity budget. Since we have to detect the OS at compile-time and manage various cargo feature flags and what-not

@zeskeertwee
Copy link
Owner

Accepting the tar CLI convention sounds interesting too, and should be doable!

@sokorototo
Copy link
Collaborator

The tar CLI is notoriously difficult to use and I am completely against adopting it. But what @omac777 is suggesting is that we adopt saving and restoring of file metadata using the CLI. I thought of a non-destructive way where additional entries are stored in the format: __metadata/{ENTRY_ID} where {ENTRY_ID} is the ID of the entry to whom the metadata belongs, this prevents mangling the spec and allows a non *nix user to easily delete the resulting metadata folder __metadata/*

@sokorototo
Copy link
Collaborator

sokorototo commented Mar 15, 2022

The CLI will use methods defined on std::fs::Metadata to retain cross-platform functionality. I still do not know how to gain superuser/Administrator access across multiple OSs. We will also have to add a new key: --preserve-metadata | -p to the CLI, turning this key on will require superuser/Administrator access. I do not know how to restore file timestamps (or if we even should) using Rust tho

@zeskeertwee
Copy link
Owner

You might need into_raw_fd for that, not sure though

@sokorototo
Copy link
Collaborator

On what I am working on at the moment, the CLI will not restore timestamps. Why? Since data can be corrupted inside the archive and the CLI won't know. Sure you can prevent this by embedding signatures but not all archives have signatures and I don't know how users feel about complicated discrepancies like such

@sokorototo
Copy link
Collaborator

into_raw_fd? Yeah what about it?

@sokorototo
Copy link
Collaborator

Does anyone have any idea how to restore file metadata using Rust? Also since MacOS is Unix-like can we have permissions restored over there too?

@sokorototo
Copy link
Collaborator

sokorototo commented Mar 22, 2022

Oh wait, std::fs::set_permissions exists

@zeskeertwee
Copy link
Owner

Does anyone have any idea how to restore file metadata using Rust? Also since MacOS is Unix-like can we have permissions restored over there too?

Wouldn't macOS just fall into std::os::unix?
(Also, you're probably going to have to use std::os::unix::fs::chown)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants