ci: update rust toolchain in matrix and dedup takeout walk by canonical path
This commit is contained in:
@@ -88,6 +88,13 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.packages_install }}
|
${{ matrix.packages_install }}
|
||||||
|
- name: Update Rust toolchain to current stable
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if command -v rustup > /dev/null 2>&1; then
|
||||||
|
rustup update stable
|
||||||
|
rustup default stable
|
||||||
|
fi
|
||||||
- name: Build artifacts
|
- name: Build artifacts
|
||||||
run: |
|
run: |
|
||||||
# Actually do builds and make zips and whatnot
|
# Actually do builds and make zips and whatnot
|
||||||
|
|||||||
@@ -7,27 +7,10 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
#[cfg(unix)]
|
|
||||||
use std::os::unix::fs::MetadataExt;
|
|
||||||
#[cfg(windows)]
|
|
||||||
use std::os::windows::fs::MetadataExt;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::logging::Logger;
|
use crate::logging::Logger;
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
fn fingerprint(metadata: &fs::Metadata) -> (u64, u64) {
|
|
||||||
(metadata.dev(), metadata.ino())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
fn fingerprint(metadata: &fs::Metadata) -> (u64, u64) {
|
|
||||||
(
|
|
||||||
u64::from(metadata.volume_serial_number().unwrap_or(0)),
|
|
||||||
metadata.file_index().unwrap_or(0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub enum FileKind {
|
pub enum FileKind {
|
||||||
Mbox,
|
Mbox,
|
||||||
@@ -76,7 +59,7 @@ pub fn walk(root: &Path) -> io::Result<WalkResult> {
|
|||||||
|
|
||||||
pub fn walk_with_logger(root: &Path, logger: Logger) -> io::Result<WalkResult> {
|
pub fn walk_with_logger(root: &Path, logger: Logger) -> io::Result<WalkResult> {
|
||||||
let mut result = WalkResult::default();
|
let mut result = WalkResult::default();
|
||||||
let mut visited: HashSet<(u64, u64)> = HashSet::new();
|
let mut visited: HashSet<PathBuf> = HashSet::new();
|
||||||
walk_dir(root, &mut result, &mut visited, logger)?;
|
walk_dir(root, &mut result, &mut visited, logger)?;
|
||||||
result.files.sort_by(|a, b| a.path.cmp(&b.path));
|
result.files.sort_by(|a, b| a.path.cmp(&b.path));
|
||||||
Ok(result)
|
Ok(result)
|
||||||
@@ -85,12 +68,11 @@ pub fn walk_with_logger(root: &Path, logger: Logger) -> io::Result<WalkResult> {
|
|||||||
fn walk_dir(
|
fn walk_dir(
|
||||||
dir: &Path,
|
dir: &Path,
|
||||||
result: &mut WalkResult,
|
result: &mut WalkResult,
|
||||||
visited: &mut HashSet<(u64, u64)>,
|
visited: &mut HashSet<PathBuf>,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
let metadata = fs::metadata(dir)?;
|
let canonical = fs::canonicalize(dir)?;
|
||||||
let key = fingerprint(&metadata);
|
if !visited.insert(canonical) {
|
||||||
if !visited.insert(key) {
|
|
||||||
result.symlink_cycles += 1;
|
result.symlink_cycles += 1;
|
||||||
logger.warn(&format!(
|
logger.warn(&format!(
|
||||||
"takeout walk: symlink cycle broken at {dir:?} (target already visited)"
|
"takeout walk: symlink cycle broken at {dir:?} (target already visited)"
|
||||||
|
|||||||
Reference in New Issue
Block a user