mirror of
https://github.com/YGGverse/pulsarss.git
synced 2026-03-31 09:05:29 +00:00
sort order index item by date desc
This commit is contained in:
parent
774a05acfe
commit
a22fa6449a
1 changed files with 10 additions and 6 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -102,14 +102,18 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
|||
// renew pending index files on items crawl completed
|
||||
if let Some(ref index_argument) = argument.index {
|
||||
for path in index {
|
||||
let subject = format!("{path}{index_argument}");
|
||||
let index_filename = format!("{path}{index_argument}");
|
||||
|
||||
// scan dir files, sort by name desc
|
||||
let mut files: Vec<_> = read_dir(&path)?.filter_map(Result::ok).collect();
|
||||
files.sort_by_key(|f| f.file_name());
|
||||
|
||||
let mut index = File::create(&subject)?;
|
||||
let mut data = Vec::with_capacity(argument.limit);
|
||||
|
||||
let mut index = File::create(&index_filename)?;
|
||||
let mut total = 0;
|
||||
for file in read_dir(&path)? {
|
||||
let name = file?.file_name().into_string().unwrap();
|
||||
|
||||
for file in files {
|
||||
let name = file.file_name().into_string().unwrap();
|
||||
|
||||
if &name == index_argument {
|
||||
continue;
|
||||
|
|
@ -124,7 +128,7 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
|||
|
||||
index.write_all(data.join("\n\n").as_bytes())?;
|
||||
|
||||
output.debug(&format!("renew `{subject}` (total: {total})"));
|
||||
output.debug(&format!("renew `{index_filename}` (total: {total})"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue