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

[BUG] mainURL can not be updated automatically. #506

Closed
Dookoen opened this issue Apr 22, 2024 · 8 comments
Closed

[BUG] mainURL can not be updated automatically. #506

Dookoen opened this issue Apr 22, 2024 · 8 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@Dookoen
Copy link

Dookoen commented Apr 22, 2024

Describe the bug
If the mainURL of a paper is missing or invalid (the pdf file is renamed of deleted), when dragging a same PDF with a different file name (user-defined) into Paperlib, the corresponding paper entry dose not update its mainURL.
The import does not work too.
I have to use choose button to relocated the new pdf file for the existing paper entry, then Paperlib will create a new pdf file with a fixed file name and use it as mainURL.
Now i have to delete the old pdf with user-defined file name.
image

The line paperEntityDraft.setValue("mainURL", payload.value); in pdf-entry-scraper.ts of entry-scrape-extension seems can update mainURL , but it does not work.

To Reproduce
Steps to reproduce the behavior:

  1. Import a pdf
  2. Rename the pdf
  3. The mainURL is invalid and 'Preview' does not work
  4. Drag or import the renamed pdf into Paperlib
  5. The mainURL is not updated and the 'Preview' does not work

Screenshots or Log
None

System (please complete the following information):

  • OS: [macOS arm]
  • Paperlib Version [3.0.9]
  • paperlib-entry-scrape-extension Version [0.0.27]

Additional context
None

@Dookoen Dookoen added the bug Something isn't working label Apr 22, 2024
@GeoffreyChen777
Copy link
Member

Hi, thanks for your donation.

This is not a bug. Everything is expected.

  1. Please never rename PDFs in finder. The filename is managed by Paperlib. We store the filename in database, and use it to access files. In preference, we provide multiple renaming formats. You can even create your own customized format.
image
  1. To replace the main file of a paper, you cannot directly drag it into the main UI as Paperlib will find that the paper is duplicated. You should use this import button, or drag it into this box:
image

It will never keep your manually renamed filename as Paperlib renames the file according to the renaing format setting.

@GeoffreyChen777 GeoffreyChen777 added question Further information is requested wontfix This will not be worked on and removed bug Something isn't working labels Apr 22, 2024
@GeoffreyChen777
Copy link
Member

Paperlib's design philosophy is that Paperlib is the sole entry for papers, and users should hardly ever need to open a file explorer to access their papers.

@Dookoen
Copy link
Author

Dookoen commented Apr 22, 2024

Thanks for you detailed explanation! Is there a method available to retrieve the existing entry or entries when a user drags PDFs into the main UI? I've reviewed the developer documentation, but it appears there's no API provided for obtaining this information. Paperlib is incredibly convenient and robust, and I'd like to incorporate this as an extension for users who wish to replace PDFs in a batched way.

@GeoffreyChen777
Copy link
Member

Emm, are you trying to check if there are any duplicated papers to your to-be-import PDFs in the library?

@Dookoen
Copy link
Author

Dookoen commented Apr 22, 2024

Not only check, i want to get id of existing entry of to-be-imported pdfs and update their mainURL.

@GeoffreyChen777
Copy link
Member

So basically, what you want to do is that:

  1. Drag PDFs into paperlib.
  2. If a PDF's corresponding paper exists in Paperlib already, then replace the original PDF.

Right?

@Dookoen
Copy link
Author

Dookoen commented Apr 22, 2024

Yeap. U r right.

@GeoffreyChen777
Copy link
Member

OK. So there is no API for this, but I think you can do it by combining multiple APIs.

  1. To get the newly imported papers before being imported to database, you can use this hook: https://paperlib.app/en/extension-doc/process-hook.html#afterscrapemetadata
  2. Then in your extension, you can check the library with PLAPI.paperService.load(). The first arg of this API is a querySentence, for example, you use title == '123' to get papers with a title 123. If the results is empty, it means that there is no duplicated paper. Otherwise, you can get the duplicated paper.

For querySentence, it's similar to the smartfilter, you can explore it there:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants