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

SAF breaks recursive copy to phone #205

Closed
rustybird opened this issue Aug 12, 2020 · 4 comments
Closed

SAF breaks recursive copy to phone #205

rustybird opened this issue Aug 12, 2020 · 4 comments

Comments

@rustybird
Copy link

rustybird commented Aug 12, 2020

On GrapheneOS (which closely tracks the latest AOSP release), SAF mode in primftpd v6.5 or older breaks when copying a directory (that didn't already exist) and its contents to my phone.

In primftpd:

I choose SAF, select the main /sdcard directory, and start the SFTP server.

On my computer:

I create a directory named dir containing three files (file-a.txt, file-b.txt, file-c.txt), and run scp -v -r dir my-phone:Documents. The output from scp (OpenSSH 8.3p1) looks fine:

Entering directory: D0775 0 dir
Sending file modes: C0664 7 file-c.txt
file-c.txt                                    100%    7     0.5KB/s   00:00    
Sending file modes: C0664 7 file-b.txt
file-b.txt                                    100%    7     0.5KB/s   00:00    
Sending file modes: C0664 7 file-a.txt
file-a.txt                                    100%    7     0.7KB/s   00:00   

But if /sdcard/Documents/dir/ didn't already exist before I ran the scp command, primftpd creates

  • an empty directory /sdcard/Documents/dir/
  • a file /sdcard/Documents/dir (1) with the content from file-c.txt
  • a file /sdcard/Documents/dir (2) with the content from file-b.txt
  • a file /sdcard/Documents/dir (3) with the content from file-a.txt

This problem doesn't occur in "plain old filesystem" mode instead of SAF.

@rustybird rustybird changed the title SAF breaks recursive copy SAF breaks recursive copy to phone Aug 12, 2020
@wolpi
Copy link
Owner

wolpi commented Aug 17, 2020

SAF API is much harder to work with than FileSystem API. It is no suprise that such bugs happen. It will take a while until I find time to look into this.

@lmagyar
Copy link
Contributor

lmagyar commented Sep 28, 2024

See #372

Here at line 72 the original version returned a SafFile for /sdcard/Documents

The proposed change still has issues line 114.

In case of plain old file-system, this is not an issue to create a file without creating a new folder, FsFile has a workaround for this here.

We should do something like FsFile in SafFile/RoSafFile, but it is hard, SafFile requires an existing parentDocument, and in this case it is nonexistent. More investigation is needed.

At least this issue helped to think about the correct solution for the #372 #373 PR-s.

@lmagyar
Copy link
Contributor

lmagyar commented Oct 3, 2024

I got it fixed in #395. This started to be a one-liner fix, but evolved into a multiday refactor project. :)

Tests are OK, now I'm testing it on my phone, I hope it will be part of the next release.

@wolpi wolpi added this to the 7.3 milestone Oct 6, 2024
@wolpi
Copy link
Owner

wolpi commented Oct 6, 2024

As the PRs are merged this should be solved.

@wolpi wolpi closed this as completed Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants