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

Fall back to system("mv $tmp $outhome") when rename() fails on Linux #65

Closed
wants to merge 4 commits into from

Conversation

marchersimon
Copy link
Contributor

@marchersimon marchersimon commented Nov 10, 2021

Fixes #64
This issue is actually two issues.
The first one is in local.h. We download the file main.zip, which contains the directory tldr-main, but we expect tldr. This was may fault in #59 (Update: I moved this fix to #66, because it's more urgent.)

But this is not the actual issue here. As already explained in #21, Linux mounts /tmp on a different filesystem than the rest of the system. We now try to move a file across two filesystems, using rename(). This isn't supported and therefore it fails. The solution is to manually copy the directory and delete the old one afterwards.

The problem here is, that this is much more complex, than simply calling a function. (Which is probably why #21 didn't get merged). For now I'm simply calling mv /tmp/tldrxxxx/tldr-main ~/.tldrc/tldr. This works perfectly on Linux and maybe on macOS, but probably not on Windows. This would be an example of a cross-platform copying function.

Since that exceeds my C knowledge I'm asking you what to do. Is this client even indented to work on Windows at all?

Update: I now switched the moving back to rename() and only call system("mv $tmp $outhome") when it fails with errno == 18, like #21 attempted. This should not break anything on macOS and fix the issue on Linux.

@marchersimon marchersimon linked an issue Nov 10, 2021 that may be closed by this pull request
@marchersimon
Copy link
Contributor Author

I just got another insight: #59 broke the client on macOS, because of the wrong name, which can be fixed pretty easily by the change I made in local.h. But (at least that's how it seems to me), on Linux, the client never actually worked all those years.

@marchersimon
Copy link
Contributor Author

marchersimon commented Nov 11, 2021

Update: I now switched the moving back to rename() and only call system("mv $tmp $outhome") if it fails with errno == 18, like #21 attempted. This should not break anything on macOS and fix the issue on Linux.

@marchersimon marchersimon marked this pull request as ready for review November 11, 2021 18:29
@marchersimon marchersimon changed the title Fix updating error Fall back to system("mv $tmp $outhome") when rename() fails on Linux Nov 11, 2021
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

Hi all! This thread has not had any recent activity.
Are there any updates? Thanks!

@github-actions
Copy link

Hi all! This thread has not had any recent activity.
Are there any updates? Thanks!

@github-actions
Copy link

Hi all! This thread has not had any recent activity.
Are there any updates? Thanks!

@github-actions
Copy link

Hi everyone.
This thread is being closed as there was no response to the previous prompt.
However, please leave a comment whenever you're ready to resume,
so the thread can be reopened. Thanks again!

@github-actions github-actions bot closed this Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when try to update local database Error: updating results in error
1 participant