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

Incremental import for singletons #1441

Closed
mried opened this issue Apr 25, 2015 · 3 comments
Closed

Incremental import for singletons #1441

mried opened this issue Apr 25, 2015 · 3 comments
Labels
feature features we would like to implement

Comments

@mried
Copy link
Contributor

mried commented Apr 25, 2015

Hi!

I just found out that the incremental import only works for directories, hence albums. Do you see a chance to enable this feature for singletons (created using the -s command line option for example)?

I had a short look at the code. Wouldn't it enough to store the file names of imported singletons beside the directories (and check them while importing, of course)? Do I overlook something why this isn't possible?

My use case is: The music library is already organised. I want to use beets to build a database and correct some tags and/or file/folder names. This happens 'in place'. Every now and than, I add an album or a singleton. The files are added directly into the library, so there is no special 'incoming' folder. To import them into beets, I run beet import -i <library root>. All already imported directories are skipped, but singletons are imported again every time.

@sampsyo sampsyo added the feature features we would like to implement label Apr 26, 2015
@sampsyo
Copy link
Member

sampsyo commented Apr 26, 2015

Yes! This would be great to add. In fact, it looks like this is halfway implemented: ImportTaskFactory.singleton already contains a check. It seems that ImportTask.save_history should also record individual items when they're imported as singletons. I say go for it!

@mried
Copy link
Contributor Author

mried commented May 3, 2015

Eh... I must admit, it's already working perfectly 😳 I stumbled over this behaviour while using my autosingleton plugin which didn't respect the incremental setting. After I fixed my plugin, everything is fine.

No, wait! There's something strange: While digging through the code and inspecting the state.pickle file, I noticed that the original file and folder names are stored. What if the files are moved during the import? They will be imported a second time. After the second import, they won't be imported any more. Shouldn't be the new file name stored here?
Another bad thing about storing the original name is: Lets say we import a file a.mp3. It's renamed to b.mp3 while importing. Later, we add a new file to our music library: a.mp3 which would be renamed to c.mp3 while importing. But: a.mp3 will not be imported any more.
While writing this another idea comes into my mind: I guess this behaviour is exactly the one you'd expect, isn't it? It's useful if the import source and the musiclibrary are distinct. So, what's needed if the import imports the library directory itself is a way to stop importing files, which are already imported, hence present at the library. I guess, I could use the import_task_created plugin hook to implement this. Any ideas?

@sampsyo
Copy link
Member

sampsyo commented May 3, 2015

OK, cool—I'm glad this is working.

That's intentional. The incremental mode needs to detect already-imported files before resolving the match and adding to the library—we need to catch them on the way in, rather than on the way out of the import process. (The ordinary duplicate detection stuff plays that role.)

Recall that incremental mode tracks the full paths—which is the best we can do. There's no more reliable way to track moved but identical files short of storing checksums.

Your idea about importing files that are not already in the library sounds good. Sort of the opposite of beet import -L, which imports everything that is already in the library. Worth prototyping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features we would like to implement
Projects
None yet
Development

No branches or pull requests

2 participants