mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
ignore remote file links in media check
This commit is contained in:
parent
f343197385
commit
9736e4a970
1 changed files with 11 additions and 0 deletions
|
@ -16,10 +16,16 @@ use crate::media::files::{
|
||||||
use crate::text::{normalize_to_nfc, MediaRef};
|
use crate::text::{normalize_to_nfc, MediaRef};
|
||||||
use crate::{media::MediaManager, text::extract_media_refs};
|
use crate::{media::MediaManager, text::extract_media_refs};
|
||||||
use coarsetime::Instant;
|
use coarsetime::Instant;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use regex::Regex;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{borrow::Cow, fs, io};
|
use std::{borrow::Cow, fs, io};
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref REMOTE_FILENAME: Regex = Regex::new("(?i)^https?://").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct MediaCheckOutput {
|
pub struct MediaCheckOutput {
|
||||||
pub unused: Vec<String>,
|
pub unused: Vec<String>,
|
||||||
|
@ -449,6 +455,11 @@ fn normalize_and_maybe_rename_files<'a>(
|
||||||
let mut field: Cow<str> = field.into();
|
let mut field: Cow<str> = field.into();
|
||||||
|
|
||||||
for media_ref in refs {
|
for media_ref in refs {
|
||||||
|
if REMOTE_FILENAME.is_match(media_ref.fname) {
|
||||||
|
// skip remote references
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// normalize fname into NFC
|
// normalize fname into NFC
|
||||||
let mut fname = normalize_to_nfc(media_ref.fname);
|
let mut fname = normalize_to_nfc(media_ref.fname);
|
||||||
// and look it up to see if it's been renamed
|
// and look it up to see if it's been renamed
|
||||||
|
|
Loading…
Reference in a new issue