Skip to content

Commit

Permalink
fix clippy #62 and test publish and package also
Browse files Browse the repository at this point in the history
  • Loading branch information
radumarias committed Jul 30, 2024
1 parent b63bfce commit a42c140
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 38 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build_and_tests_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- name: build
run: |
cargo build --all-targets --all-features
cargo build --release --all-targets --all-features
cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu
cargo build --release --all-targets --all-features --target x86_64-unknown-linux-gnu
- name: fmt check
run: cargo fmt --all --check
Expand All @@ -28,7 +28,15 @@ jobs:
run: cargo check --all-targets

- name: tests
run: cargo test --release --all-features
run: cargo test --release --all-features --target x86_64-unknown-linux-gnu

- name: test publish
run: cargo publish --dry-run --allow-dirty
run: cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu

- name: test publish
run: cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu

- name: test package
run: |
cargo aur
cargo generate-rpm
24 changes: 12 additions & 12 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0 # TODO: remove this when we cache the builds
Expand All @@ -16,19 +16,19 @@ jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Rust
run: rustup update
- name: Setup Rust
run: rustup update

- name: build
run: cargo build --all --release
- name: build
run: cargo build --all --release --target x86_64-unknown-linux-gnu

- name: fmt check
run: cargo fmt --all -- --check
- name: fmt check
run: cargo fmt --all -- --check

- name: check
run: cargo check --all --release
- name: check
run: cargo check --all --release

- name: clippy
run: cargo clippy --all
- name: clippy
run: cargo clippy --all
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ depends = ["fuse3"]
files = [
["LICENSE-Apache-2.0", "/usr/share/licenses/$pkgname/LICENSE-Apache-2.0"],
["LICENSE-MIT", "/usr/share/licenses/$pkgname/LICENSE-MIT"],
# ["LICENSE-BSD-3-Clause", "/usr/share/licenses/$pkgname/LICENSE-BSD-3-Clause"]
["LICENSE-BSD-3-Clause", "/usr/share/licenses/$pkgname/LICENSE-BSD-3-Clause"]
]

[package.metadata.generate-rpm]
Expand Down
21 changes: 15 additions & 6 deletions check-before-push.bat
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
cargo build --all --all-features
if %errorlevel% neq 0 exit /b %errorlevel%

cargo build --release --all --all-features
cargo build --all --all-features --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo build --release --all --all-features --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo fmt --all -- --check
if %errorlevel% neq 0 exit /b %errorlevel%

cargo check --all
cargo check --all --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo clippy --all --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo clippy --all
cargo test --release --all --all-features --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo test --release --all --all-features
cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu
if %errorlevel% neq 0 exit /b %errorlevel%

cargo publish --dry-run --allow-dirty
if %errorlevel% neq 0 exit /b %errorlevel%
cargo aur
if %errorlevel% neq 0 exit /b %errorlevel%

cargo generate-rpm
if %errorlevel% neq 0 exit /b %errorlevel%
14 changes: 8 additions & 6 deletions check-before-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

set -e

cargo build --all --all-features
cargo build --release --all --all-features
cargo build --all --all-features --target x86_64-unknown-linux-gnu
cargo build --release --all --all-features --target x86_64-unknown-linux-gnu
cargo fmt --all -- --check
cargo check --all
cargo clippy --all
cargo test --release --all --all-features
cargo publish --dry-run --allow-dirty
cargo check --all --target x86_64-unknown-linux-gnu
cargo clippy --all --target x86_64-unknown-linux-gnu
cargo test --release --all --all-features --target x86_64-unknown-linux-gnu
cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu
cargo aur
cargo generate-rpm
21 changes: 14 additions & 7 deletions src/encryptedfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ impl EncryptedFs {
let fhs = self.opened_files_for_read.read().await.get(&ino).cloned();
if let Some(fhs) = fhs {
for fh in fhs {
if let Some(ctx) = self.read_handles.read().await.get(&fh) {
let lock = self.read_handles.read().await;
if let Some(ctx) = lock.get(&fh) {
let set_atr: SetFileAttr = ctx.lock().await.attr.clone().into();
merge_attr(&mut attr, &set_atr, false);
}
Expand All @@ -1255,7 +1256,8 @@ impl EncryptedFs {
if open_writes {
let fh = self.opened_files_for_write.read().await.get(&ino).copied();
if let Some(fh) = fh {
if let Some(ctx) = self.write_handles.read().await.get(&fh) {
let lock = self.write_handles.read().await;
if let Some(ctx) = lock.get(&fh) {
let ctx = ctx.lock().await;
merge_attr(&mut attr, &ctx.attr.clone().into(), false);
}
Expand Down Expand Up @@ -1552,8 +1554,10 @@ impl EncryptedFs {
// in the case of directory or if the file was crated without being opened we don't use a handle
return Ok(());
}
let mut valid_fh = self.read_handles.read().await.get(&handle).is_some();
if let Some(ctx) = self.write_handles.read().await.get(&handle) {
let lock = self.read_handles.read().await;
let mut valid_fh = lock.get(&handle).is_some();
let lock = self.write_handles.read().await;
if let Some(ctx) = lock.get(&handle) {
let mut ctx = ctx.lock().await;
let lock = self
.read_write_locks
Expand Down Expand Up @@ -1970,7 +1974,8 @@ impl EncryptedFs {
let path = self.contents_path(ino);

// read
if let Some(set) = self.opened_files_for_read.read().await.get(&ino) {
let lock = self.opened_files_for_read.read().await;
if let Some(set) = lock.get(&ino) {
for handle in set
.iter()
.filter(|h| skip_write_fh.map_or(true, |fh| **h != fh))
Expand All @@ -1989,13 +1994,15 @@ impl EncryptedFs {
}

// write
if let Some(fh) = self.opened_files_for_write.read().await.get(&ino) {
let lock = self.opened_files_for_write.read().await;
if let Some(fh) = lock.get(&ino) {
if let Some(handle) = skip_write_fh {
if *fh == handle {
return Ok(());
}
}
if let Some(lock) = self.write_handles.read().await.get(fh) {
let lock = self.write_handles.read().await;
if let Some(lock) = lock.get(fh) {
let mut ctx = lock.lock().await;
let writer = ctx.writer.as_mut().unwrap();
let file = writer.finish()?;
Expand Down
3 changes: 2 additions & 1 deletion src/expire_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ impl<
}

async fn get_from_ref_or_cache(&self) -> Option<Arc<T>> {
if let Some(ref weak) = *self.weak.read().await {
let lock = self.weak.read().await;
if let Some(ref weak) = *lock {
// try to take it from weak ref
if let Some(ref v) = weak.upgrade() {
return Some(v.clone());
Expand Down

0 comments on commit a42c140

Please sign in to comment.