unidoc / unipdf-cli

CLI for PDF processing using unipdf
Other
106 stars 15 forks source link

Invalid Cross-Device Link #63

Open deon-gracias opened 5 hours ago

deon-gracias commented 5 hours ago

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.

image

sampila commented 4 hours ago

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 % 
deon-gracias commented 4 hours ago

No I haven't, but I still re-cloned the repository and tried again. This was the result.

image

I also checked if I have some other /tmp/unipdf_sample.pdf in my file doing a ls grep but nothing showed up

image

sampila commented 4 hours ago

Could you share your pdf file?

Hard to debug if unable to reproduce the issue

deon-gracias commented 4 hours ago

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

sample.pdf

sampila commented 3 hours ago

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

sample.pdf

Yes, I am unable to reproduce it.

Screenshot 2024-09-22 at 02 07 21