foss_storage #3
@@ -8,7 +8,7 @@ use surrealdb::{
 | 
			
		||||
    Surreal,
 | 
			
		||||
};
 | 
			
		||||
use tokio::sync::Mutex;
 | 
			
		||||
use tracing::{error, instrument, trace, warn};
 | 
			
		||||
use tracing::{error, instrument, trace};
 | 
			
		||||
use url::Url;
 | 
			
		||||
 | 
			
		||||
use crate::Config;
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ use url::Url;
 | 
			
		||||
pub async fn store(data: &str, url: &Url) {
 | 
			
		||||
    let path = PathBuf::from("./downloaded".to_string() + url.path());
 | 
			
		||||
    let basepath = path.ancestors().skip(1).take(1).collect::<PathBuf>();
 | 
			
		||||
    trace!("Built path: {:?} and base path: {:?}", &path, &basepath);
 | 
			
		||||
    trace!("Save path: {:?} and base path: {:?}", &path, &basepath);
 | 
			
		||||
    if let Err(err) = fs::create_dir_all(&basepath).await {
 | 
			
		||||
        let ex = path.ancestors().fold(String::new(), |mut s, item| {
 | 
			
		||||
            s += ", ";
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
extern crate html5ever;
 | 
			
		||||
 | 
			
		||||
use std::{
 | 
			
		||||
    collections::HashSet, fs::File, io::Read, net::{IpAddr, Ipv4Addr}, str::FromStr, time
 | 
			
		||||
    collections::HashSet, fs::File, io::Read, net::{IpAddr, Ipv4Addr}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
use db::{connect, Website};
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ use html5ever::tokenizer::{BufferQueue, TokenizerResult};
 | 
			
		||||
use html5ever::tokenizer::{StartTag, TagToken};
 | 
			
		||||
use html5ever::tokenizer::{Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts};
 | 
			
		||||
use html5ever::{local_name, tendril::*};
 | 
			
		||||
use tracing::{debug, error, info, instrument, trace, warn};
 | 
			
		||||
use tracing::{debug, error, instrument, trace, warn};
 | 
			
		||||
use url::Url;
 | 
			
		||||
 | 
			
		||||
use crate::db::Website;
 | 
			
		||||
@@ -41,7 +41,7 @@ impl TokenSink for Website {
 | 
			
		||||
                                            Some(ok)
 | 
			
		||||
                                        },
 | 
			
		||||
                                        Err(e) => {
 | 
			
		||||
                                            if attr.value.eq(&Tendril::from_char('#')) {
 | 
			
		||||
                                            if attr.value.starts_with('#') {
 | 
			
		||||
                                                trace!("Rejecting # url");
 | 
			
		||||
                                                None
 | 
			
		||||
                                            } else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user