mirror of
https://github.com/ankitects/anki.git
synced 2026-01-08 03:23:54 -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
|
jariji
|
||||||
Francisco Esteva <fr.esteva@duocuc.cl>
|
Francisco Esteva <fr.esteva@duocuc.cl>
|
||||||
SelfishPig <https://github.com/SelfishPig>
|
SelfishPig <https://github.com/SelfishPig>
|
||||||
|
Brett Schwartz <brettschwartz871@gmail.com>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -552,6 +552,8 @@ pub(crate) mod test {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::collection::CollectionBuilder;
|
use crate::collection::CollectionBuilder;
|
||||||
|
use crate::sync::media::MAX_MEDIA_FILENAME_LENGTH;
|
||||||
|
use crate::tests::NoteAdder;
|
||||||
|
|
||||||
fn common_setup() -> Result<(TempDir, MediaManager, Collection)> {
|
fn common_setup() -> Result<(TempDir, MediaManager, Collection)> {
|
||||||
let dir = tempdir()?;
|
let dir = tempdir()?;
|
||||||
|
|
@ -869,4 +871,30 @@ Unused: unused.jpg
|
||||||
|
|
||||||
Ok(())
|
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