unipdf-cli
unipdf-cli copied to clipboard
Invalid Cross-Device Link
While trying to run a split on a pdf and writing it to the same area. I get this error of Invalid Cross-Device.
Going through the source code and messing I came to know it's cause of the os.Rename done in pkg/pdf/utils.go specifically in writePdf function on line 83.
The fix I found for it was just simply copying the file to the TEMP_DIR but then there's an issue that we cannot delete the file from TEMP_DIR when it is /tmp due to access rights I think.
Hi @deon-gracias do you modify the unipdf-cli code?
I tried but can't reproduce the issue.
alip@alips unipdf % go run main.go split ~/unipdf-security-report-3.pdf ~/unipdf-security-report-3.pdf 1
Successfully split file ~/unipdf-security-report-3.pdf
Output file saved to ~/unipdf-security-report-3.pdf
alip@alips unipdf %
No I haven't, but I still re-cloned the repository and tried again. This was the result.
I also checked if I have some other /tmp/unipdf_sample.pdf in my file doing a ls grep but nothing showed up
Could you share your pdf file?
Hard to debug if unable to reproduce the issue
I'm sure its not the pdf that is the issue but here you go. I'll also look into some solutions, other than just copying the file to the /tmp dir
I'm sure its not the pdf that is the issue but here you go. I'll also look into some solutions, other than just copying the file to the
/tmpdir
Yes, I am unable to reproduce it.
I got it to work after changing the temp file location in the writePDF().
The issue is that by default on /tmp which is the problem. Creating a folder in the users /home/$USER dir works fine.
I got it to work after changing the temp file location in the
writePDF().
The issue is that by default on
/tmpwhich is the problem. Creating a folder in the users/home/$USERdir works fine.
Normally, it should call the temporary directory using os.TempDir() like here
https://github.com/unidoc/unipdf-cli/blob/9dfe4f14cd22cc49c7a406356416128273803237/pkg/pdf/utils.go#L82
Yes and the os.TempDir() for me returns /tmp path
Pretty strange, can try with other pdf? seems file permission issue to me, as I can't reproduce the issue also here.
Yea the only thing I can think about is / is in root so its not allowing it to rename the file created in /tmp.
So, I am closing this issue for now, as I can't reproduce it on my end.
Feel free to re-open the issue if there's a way to reproduce the issue and we will re-open this also if we found way to reproduce and confirm this issue.

