Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 36 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description = "Universal static analysis, stress testing, and logic-based bug si
repository = "https://github.com/hyperpolymath/panic-attack"

[dependencies]
tree-sitter = "=0.27.1"
tree-sitter = "=0.27.2"
tree-sitter-php = "=0.25.1"
tree-sitter-html = "=0.23.2"
tree-sitter-css = "=0.25.0"
Expand All @@ -34,7 +34,6 @@ ijson-jcs = { git = "https://github.com/hyperpolymath/ijson-jcs", rev = "03df9ed
serde-saphyr = "2.0"
regex = "1.10"
chrono = "0.4"
filetime = "0.2"
encoding_rs = "0.8"
crossterm = "0.29"
eframe = { version = "0.37", optional = true }
Expand Down
23 changes: 18 additions & 5 deletions src/abduct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

use crate::assail;
use anyhow::{anyhow, Context, Result};
use filetime::FileTime;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeSet, HashMap, HashSet, VecDeque};
use std::fs;
use std::fs::{self, File, FileTimes};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::{Duration, Instant};
use std::time::{Duration, Instant, SystemTime};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DependencyScope {
Expand Down Expand Up @@ -434,11 +433,25 @@ fn apply_mtime_offset(files: &mut [AbductFileRecord], days: i64) -> Result<usize
let now = chrono::Utc::now();
let shifted = now + chrono::Duration::days(days);
let timestamp = shifted.timestamp();
let ft = FileTime::from_unix_time(timestamp, 0);
let when = if timestamp >= 0 {
SystemTime::UNIX_EPOCH + Duration::from_secs(timestamp.unsigned_abs())
} else {
SystemTime::UNIX_EPOCH - Duration::from_secs(timestamp.unsigned_abs())
};
let times = FileTimes::new().set_accessed(when).set_modified(when);

let mut shifted_count = 0usize;
for file in files {
filetime::set_file_times(&file.destination, ft, ft)
// Write access is the portable requirement for `File::set_times`; a
// read-only copy falls back to a read handle, which Unix accepts for
// the file's owner.
let handle = File::options()
.write(true)
.open(&file.destination)
.or_else(|_| File::open(&file.destination))
.with_context(|| format!("opening {} to set mtime", file.destination.display()))?;
handle
.set_times(times)
.with_context(|| format!("setting mtime for {}", file.destination.display()))?;
file.mtime_shifted = true;
shifted_count += 1;
Expand Down
Loading