Skip to content

Run git init in collection.media/ at clone time #110

@langfield

Description

@langfield

This is an optimization first conceived of in #39 (comment). We first run git init in the media directory. Then we detect unused media using an API call to whatever backend function Anki uses to check its media. We add all these files to the .gitignore. All files are committed, and then we clone this repository locally within the nascent ki repo. This serves as the top-level _media/ directory.

On pulls, we only check the notes that have been edited, and from those we munge the fields looking for media filenames. We remove any media filenames we find from the .gitignore if they're there, and then commit in the media directory. Then we pull from the media directory to our local submodule, _media/.

Another idea is to concatenate every field of every note (maybe in batches to avoid running out of memory) and then run media_filenames_in_field() on that whole blob. This is just another way to detect what media files are being used in the whole collection, and thus probably not very useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions