diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 76b5f3ac..8c0517ca 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -51,6 +51,7 @@ use path_absolutize::Absolutize; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::io::SeekFrom; +#[cfg(unix)] use std::os::unix::fs::MetadataExt; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; @@ -383,7 +384,7 @@ impl LocalDisk { kind => { if kind.to_string() != "directory not empty" { warn!("delete_file remove_dir {:?} err {}", &delete_path, kind.to_string()); - return Err(Error::from(err)); + return Err(Error::new(DiskError::FileAccessDenied)); } } } @@ -395,7 +396,7 @@ impl LocalDisk { ErrorKind::NotFound => (), _ => { warn!("delete_file remove_file {:?} err {:?}", &delete_path, &err); - return Err(Error::from(err)); + return Err(Error::new(DiskError::FileAccessDenied)); } } } @@ -743,12 +744,10 @@ impl LocalDisk { .await .map_err(os_err_to_file_err)?; - // let mut data = Vec::new(); - // let n = file.read_to_end(&mut data).await?; - let meta = file.metadata().await?; + let file_size = meta.len() as usize; - bitrot_verify(Box::new(file), meta.size() as usize, part_size, algo, sum.to_vec(), shard_size).await + bitrot_verify(Box::new(file), file_size, part_size, algo, sum.to_vec(), shard_size).await } async fn scan_dir( diff --git a/ecstore/src/utils/os/windows.rs b/ecstore/src/utils/os/windows.rs index 432e90e6..a99d7001 100644 --- a/ecstore/src/utils/os/windows.rs +++ b/ecstore/src/utils/os/windows.rs @@ -1,7 +1,8 @@ #![allow(unsafe_code)] // TODO: audit unsafe code use super::IOStats; -use crate::{disk::Info, error::Result}; +use crate::disk::Info; +use common::error::Result; use std::io::{Error, ErrorKind}; use std::mem; use std::os::windows::ffi::OsStrExt; diff --git a/rustfs/src/logging/mod.rs b/rustfs/src/logging/mod.rs index e69de29b..8b137891 100644 --- a/rustfs/src/logging/mod.rs +++ b/rustfs/src/logging/mod.rs @@ -0,0 +1 @@ + diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 3cee79f2..f517220a 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -586,8 +586,8 @@ impl S3 for FS { .await .is_ok() || authorize_request(&mut req, Action::S3Action(S3Action::GetBucketLocationAction)) - .await - .is_ok() + .await + .is_ok() }) }); } @@ -1256,7 +1256,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let write_olny = PolicySys::is_allowed(&BucketPolicyArgs { bucket: &bucket, @@ -1267,7 +1267,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let is_public = read_olny && write_olny; @@ -1680,11 +1680,11 @@ impl S3 for FS { // TODO: valid target list if let Some(NotificationConfiguration { - event_bridge_configuration, - lambda_function_configurations, - queue_configurations, - topic_configurations, - }) = has_notification_config + event_bridge_configuration, + lambda_function_configurations, + queue_configurations, + topic_configurations, + }) = has_notification_config { Ok(S3Response::new(GetBucketNotificationConfigurationOutput { event_bridge_configuration, @@ -1785,10 +1785,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1855,10 +1855,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1934,9 +1934,9 @@ impl S3 for FS { } #[allow(dead_code)] -pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static +pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static where - S: Stream> + Send + 'static, + S: Stream> + Send + 'static, E: Send + 'static, { AsyncTryStream::::new(|mut y| async move { diff --git a/rustfs/static/readme.md b/rustfs/static/readme.md deleted file mode 100644 index 325303e1..00000000 --- a/rustfs/static/readme.md +++ /dev/null @@ -1 +0,0 @@ -console static path, do not delete \ No newline at end of file diff --git a/scripts/run.bat b/scripts/run.bat deleted file mode 100644 index 0dd48a44..00000000 --- a/scripts/run.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -rem filepath: run.bat - -if not defined SKIP_BUILD ( - cargo build -p rustfs --bins -) - -set current_dir=%cd% - -if not exist .\target\volume\test mkdir .\target\volume\test - -if not defined RUST_LOG ( - set RUST_BACKTRACE=1 - set RUST_LOG=rustfs=debug,ecstore=debug,s3s=debug,iam=debug -) - -rem set RUSTFS_ERASURE_SET_DRIVE_COUNT=5 - -rem set RUSTFS_STORAGE_CLASS_INLINE_BLOCK=512 KB - -rem set RUSTFS_VOLUMES=.\target\volume\test{0...4} -set RUSTFS_VOLUMES=.\target\volume\test -set RUSTFS_ADDRESS=0.0.0.0:9000 -set RUSTFS_CONSOLE_ENABLE=true -set RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 -rem set RUSTFS_SERVER_DOMAINS=localhost:9000 -rem 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 -set RUSTFS_OBS_CONFIG=.\config\obs.example.toml" - -if not "%~1"=="" ( - set RUSTFS_VOLUMES=%~1 -) - -cargo run --bin rustfs \ No newline at end of file diff --git a/scripts/run.ps1 b/scripts/run.ps1 new file mode 100644 index 00000000..a6ab92fb --- /dev/null +++ b/scripts/run.ps1 @@ -0,0 +1,51 @@ +# Check if static files need to be downloaded +if (-not (Test-Path .\rustfs\static\index.html)) { + Write-Host "Downloading rustfs-console-latest.zip" + + Invoke-WebRequest -Uri "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -OutFile 'tempfile.zip' + Expand-Archive -Path 'tempfile.zip' -DestinationPath '.\rustfs\static' -Force + Remove-Item tempfile.zip +} + +# Check if build should be skipped +if (-not $env:SKIP_BUILD) { + cargo build -p rustfs --bins +} + +$current_dir = Get-Location + +# Create multiple test directories +$testDirs = @("test0", "test1", "test2", "test3", "test4") +foreach ($dir in $testDirs) { + $path = Join-Path -Path ".\target\volume" -ChildPath $dir + if (-not (Test-Path $path)) { + New-Item -ItemType Directory -Path $path -Force | Out-Null + } +} + +# Set environment variables +if (-not $env:RUST_LOG) { + $env:RUST_BACKTRACE = 1 + $env:RUST_LOG = "rustfs=debug,ecstore=debug,s3s=debug,iam=debug" +} + +# The following environment variables are commented out, uncomment them if needed +# $env:RUSTFS_ERASURE_SET_DRIVE_COUNT = 5 +# $env:RUSTFS_STORAGE_CLASS_INLINE_BLOCK = "512 KB" + +$env:RUSTFS_VOLUMES = ".\target\volume\test{0...4}" +# $env:RUSTFS_VOLUMES = ".\target\volume\test" +$env:RUSTFS_ADDRESS = "127.0.0.1:9000" +$env:RUSTFS_CONSOLE_ENABLE = "true" +$env:RUSTFS_CONSOLE_ADDRESS = "127.0.0.1:9002" +# $env:RUSTFS_SERVER_DOMAINS = "localhost:9000" +# Change to the actual configuration file path, obs.example.toml is for reference only +$env:RUSTFS_OBS_CONFIG = ".\config\obs.example.toml" + +# Check command line arguments +if ($args.Count -gt 0) { + $env:RUSTFS_VOLUMES = $args[0] +} + +# Run the program +cargo run --bin rustfs \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh index cc964bee..4defb1f1 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -39,7 +39,7 @@ fi if [ ! -f ./rustfs/static/index.html ]; then echo "Downloading rustfs-console-latest.zip" # download rustfs-console-latest.zip do not show log - curl -s -L "https://dl.rustfs.com/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip + curl -s -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip fi cargo run --bin rustfs \ No newline at end of file