[-] Remove listing generation
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
use crate::macros::*;
|
|
||||||
use crate::utils::*;
|
use crate::utils::*;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@@ -16,13 +14,6 @@ use crate::thumbnailer::{Thumbnailers};
|
|||||||
|
|
||||||
const DOT_PATH: &str = ".meow_index";
|
const DOT_PATH: &str = ".meow_index";
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
|
||||||
pub struct ReturnPath {
|
|
||||||
pub(crate) name: String,
|
|
||||||
pub(crate) file_type: String,
|
|
||||||
pub(crate) mtime: i64
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Generator {
|
pub struct Generator {
|
||||||
pub(crate) mime_db: SharedMimeInfo,
|
pub(crate) mime_db: SharedMimeInfo,
|
||||||
pub(crate) thumbnailers: Thumbnailers,
|
pub(crate) thumbnailers: Thumbnailers,
|
||||||
@@ -112,24 +103,6 @@ impl Generator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if directory listing needs update
|
|
||||||
let d_info = self.dot_path(&dir).with_extension(".json");
|
|
||||||
let d_mtime = d_info.metadata()?.mtime();
|
|
||||||
if files.iter().any(|(f, m)| m.mtime() > d_mtime) {
|
|
||||||
// Update directory listing
|
|
||||||
let paths: Vec<ReturnPath> = files.iter()
|
|
||||||
.filter_map(|(f, m)| Some(ReturnPath {
|
|
||||||
name: f.file_name().to_str()?.to_string(),
|
|
||||||
file_type: f.path().file_type().to_string(),
|
|
||||||
mtime: m.mtime(),
|
|
||||||
})).collect();
|
|
||||||
|
|
||||||
let json = serde_json::to_string(&paths)?;
|
|
||||||
// fs::write(d_info, json)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -4,16 +4,19 @@ mod generator;
|
|||||||
mod utils;
|
mod utils;
|
||||||
mod thumbnailer;
|
mod thumbnailer;
|
||||||
|
|
||||||
|
use generator::*;
|
||||||
|
use macros::*;
|
||||||
|
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
use std::path::Path;
|
||||||
use hyper::{Body, http, Request, Response, Server};
|
use hyper::{Body, http, Request, Response, Server};
|
||||||
use hyper::service::{make_service_fn, service_fn};
|
use hyper::service::{make_service_fn, service_fn};
|
||||||
use path_clean::{clean};
|
use path_clean::{clean};
|
||||||
use macros::StringExt;
|
use anyhow::{Result};
|
||||||
use crate::macros::PathExt;
|
use serde::{Deserialize, Serialize};
|
||||||
use generator::*;
|
|
||||||
|
|
||||||
extern crate pretty_env_logger;
|
extern crate pretty_env_logger;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
|||||||
Reference in New Issue
Block a user