media.py sets CWD to the media directory of the collection
(collection.media), and relies on that directory being
maintained as CWD throughout execution. The original CWD
is restored in the close() function.
Remove reliance on CWD being set and maintained throughout
execution of media.py. Improves portability and usability
in different codebases.
fixes the following:
- create a filtered deck and sync it
- review cards in the filtered deck and delete it
- sync again
The filtered deck deletion was bumping the mod time on cards at the
start of the sync, preventing the reviews from being synced from the
other side, leading to lost reviews and sanity check errors.
commit 79ed57a445 prevented reschedule
on cards in a filtered deck, but it is more user friendly to
automatically move back to the home deck instead. we also don't need
to removeLrn() for review cards, because we're updating type+queue+odue
ourselves
- /sync/meta now returns a dictionary
- it includes the following extra fields
- msg: if non-empty, show this message at the end of the sync
- cont: if false, show above message and abort sync
- uname: the user's email address, so it can be stored by the local client to
show users who have forgotten which email address they used. in the future
this will be saved only when logging in, so do a conditional access on it
- always store media references in fields in NFC form
- always encode filenames on disk in NFC form on machines other than macs
- use relevant encoding when placing files in the media folder during syncs
and apkg imports as well
- rename 'unused media' back to 'check media'
- check media can now automatically change media references and filename
encodings to the correct format
First, burying changes:
- unburying now happens on day rollover, or when manually unburying from
overview screen
- burying is not performed when returning to deck list, or when closing
collection, so burying now must mark cards as modified to ensure sync
consistent
- because they're no longer temporary to a session, make sure we exclude them
in filtered decks in -is:suspended
Sibling spacing changes:
- core behaviour now based on automatically burying related cards when we
answer a card
- applies to reviews, optionally to new cards, and never to cards in the
learning queue (partly because we can't suspend/bury cards in that queue at
the moment)
- this means spacing works consistently in filtered decks now, works on
reviews even when user is late to review, and provides better separation of
new cards
- if burying new cards disabled, we just discard them from the current queue.
an option to set due=ord*space+due would be nicer, but would require
changing a lot of code and is more appropriate for a future major version
change. discarding from queue suffers from the same issue as the new card
cycling in that queue rebuilds may cause cards to be shown close together,
so the default burying behaviour is preferable
- refer to them as 'related cards' rather than 'siblings'
These changes don't require any changes to the database format, so they
should hopefully coexist with older clients without issue.
- add writeData() so we can add files to media folder without having to
save them in an intermediate folder first
- we were stripping or checking for illegal filename characters in
multiple places; factor those checks out into separate routines
- add * to invalid char list, and disallow both forward and backslash
- remove size checks in syncAdd(); is handled server-side
- split quoted and unquoted image case into separate regexps, since we can't
include a group reference inside a character set
- disallow spaces in the non-quoted case
- this should fix matching on images with other attributes again