mirror of
https://github.com/ankitects/anki.git
synced 2026-01-05 18:13:56 -05:00
Merge fc2166893d into 8f2144534b
This commit is contained in:
commit
3468705a0b
2 changed files with 29 additions and 0 deletions
|
|
@ -256,6 +256,7 @@ Eltaurus <https://github.com/Eltaurus-Lt>
|
|||
jariji
|
||||
Francisco Esteva <fr.esteva@duocuc.cl>
|
||||
SelfishPig <https://github.com/SelfishPig>
|
||||
Brett Schwartz <brettschwartz871@gmail.com>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
|||
|
|
@ -552,6 +552,8 @@ pub(crate) mod test {
|
|||
|
||||
use super::*;
|
||||
use crate::collection::CollectionBuilder;
|
||||
use crate::sync::media::MAX_MEDIA_FILENAME_LENGTH;
|
||||
use crate::tests::NoteAdder;
|
||||
|
||||
fn common_setup() -> Result<(TempDir, MediaManager, Collection)> {
|
||||
let dir = tempdir()?;
|
||||
|
|
@ -869,4 +871,30 @@ Unused: unused.jpg
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_filename_rename_not_reported_as_unused() -> Result<()> {
|
||||
let (_dir, mgr, mut col) = common_setup()?;
|
||||
|
||||
let long_filename = format!("{}.mp3", "a".repeat(MAX_MEDIA_FILENAME_LENGTH + 1));
|
||||
|
||||
NoteAdder::basic(&mut col)
|
||||
.fields(&["test", &format!("[sound:{}]", long_filename)])
|
||||
.add(&mut col);
|
||||
|
||||
write_file(mgr.media_folder.join(&long_filename), "audio data")?;
|
||||
|
||||
let output = {
|
||||
let mut checker = col.media_checker()?;
|
||||
checker.check()?
|
||||
};
|
||||
|
||||
assert!(output.renamed.contains_key(&long_filename));
|
||||
let new_filename = output.renamed.get(&long_filename).unwrap();
|
||||
assert!(new_filename.len() <= MAX_MEDIA_FILENAME_LENGTH);
|
||||
assert!(!output.unused.contains(new_filename));
|
||||
assert!(!output.missing.contains(new_filename));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue