Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: opendal compat doesn't work as expected #5235

Closed
1 task done
Xuanwo opened this issue Oct 24, 2024 · 0 comments · Fixed by #5236
Closed
1 task done

bug: opendal compat doesn't work as expected #5235

Xuanwo opened this issue Oct 24, 2024 · 0 comments · Fixed by #5236
Labels
bug Something isn't working

Comments

@Xuanwo
Copy link
Member

Xuanwo commented Oct 24, 2024

Describe the bug

Rust doesn't make sure to generate the same layout for the same struct defination.

Read https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html for more.

[src/v0_50_to_v0_49.rs:69:9] &new_info = AccessorInfo {
    scheme: Memory,
    root: "/",
    name: "0x7f3a1c00bc60",
    native_capability: { Stat | Read | Write | Delete | List | Blocking },
    full_capability: { Stat | Read | Write | CreateDir | Delete | List | Blocking },
}
[src/v0_50_to_v0_49.rs:71:9] &old_info = AccessorInfo {
    scheme: Memory,
    root: "/",
    name: "0x7f3a1c00bc60",
    native_capability: { Stat | List | Presign },
    full_capability: { Stat | Rename | List | Presign },
}

Steps to Reproduce

use opendal_v0_50 as new_o;

#[tokio::test]
async fn test_read() {
    let new_op = new_o::Operator::from_config(new_o::services::MemoryConfig::default())
        .unwrap()
        .finish();
    let old_op = opendal_compat::v0_50_to_v0_49(new_op);

    old_op.write("test", "hello, world!").await.unwrap();
    let bs = old_op.read("test").await.unwrap();
    assert_eq!(String::from_utf8_lossy(&bs.to_vec()), "hello, world!");
}

This test will failed for:

called `Result::unwrap()` on an `Err` value: Unsupported (permanent) at write => service memory doesn't support operation write

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    v0_50_to_v0_49::tests::test_read

Expected Behavior

We expect both read and write can work correctly.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant