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

Use patched fuser crate #8997

Draft
wants to merge 17 commits into
base: releases/3.2
Choose a base branch
from
Draft
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
32 changes: 20 additions & 12 deletions .github/workflows/package-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,29 @@ jobs:
matrix:
include:
- name: 🏁 Windows
platform: windows
os: windows-2022
raw_latest_file: latest.yml
artifact_tag: windows-exe
cache-rust: false
extension: exe
os_alias: win
artifact_tag: windows-exe
os: windows-2022
platform: windows
raw_latest_file: latest.yml
- name: 🍎 macOS
platform: macos
os: macos-13
raw_latest_file: latest-mac.yml
artifact_tag: macos-dmg
cache-rust: true
extension: "*" # Use wildcard to match dmg and zip extension
os_alias: mac
artifact_tag: macos-dmg
os: macos-13
platform: macos
raw_latest_file: latest-mac.yml
- name: 🐧 AppImage 4 Linux
platform: linux
artifact_tag: linux-appimage
cache-rust: false
extension: AppImage
os_alias: linux
os: ubuntu-22.04
platform: linux
raw_latest_file: latest-linux.yml
os_alias: linux
extension: AppImage
artifact_tag: linux-appimage
name: "${{matrix.name }}: ⚡ Package electron"
runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand Down Expand Up @@ -333,6 +336,10 @@ jobs:
working-directory: bindings/electron
timeout-minutes: 1

- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # pin v1.10.1
if: matrix.cache-rust || false
timeout-minutes: 10

- name: Build Electron bindings
run: npm run build:release
working-directory: bindings/electron
Expand Down Expand Up @@ -373,6 +380,7 @@ jobs:
run: |
if ${{ matrix.platform == 'macos' }}; then
# export DEBUG='electron-notarize*'
export CSC_FOR_PULL_REQUEST='${{ github.actor == 'FirelightFlagboy' }}'
export CSC_LINK='${{ secrets.MACOS_CERT }}'
export CSC_KEY_PASSWORD='${{ secrets.MACOS_CERT_PASSWD }}'
export CSC_NAME='${{ secrets.MACOS_CERT_COMMON_NAME }}'
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ eventsource-stream = { version = "0.2.3", default-features = false }
flate2 = { version = "1.0.34", features = ["rust_backend"], default-features = false }
flume = { version = "0.11.1", default-features = false }
fnmatch-regex = { version = "0.2.1", default-features = false }
fuser = { version = "0.15.0", default-features = false }
fuser = { version = "0.15.1", default-features = false }
futures = { version = "0.3.31", default-features = false }
generic-array = { version = "0.14.7", default-features = false }
getrandom = { package = "getrandom", version = "0.2.15", default-features = false }
Expand Down Expand Up @@ -177,7 +177,7 @@ rpassword = { version = "7.3.1", default-features = false }
rsa = { version = "0.8.2", default-features = false }
rstest = { version = "0.18.2", default-features = false }
rstest_reuse = { version = "0.6.0", default-features = false }
ruzstd = { version = "0.7.2", default-features = true }
ruzstd = { version = "0.7.3", default-features = true }
sentry = { version = "0.34.0", default-features = false }
sentry-log = { version = "0.34.0", default-features = false }
serde = { version = "1.0.214", default-features = false }
Expand Down
8 changes: 1 addition & 7 deletions bindings/electron/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,14 +1129,8 @@ export type DeviceSaveStrategy =
export interface EntryStatFile {
tag: "File"
confinement_point: string | null
id: string
parent: string
created: number
updated: number
base_version: number
is_placeholder: boolean
need_sync: boolean
size: number
base: FileStat
}
export interface EntryStatFolder {
tag: "Folder"
Expand Down
4 changes: 3 additions & 1 deletion bindings/electron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ fn init_sentry() {

#[neon::main]
pub fn main(mut cx: ModuleContext) -> NeonResult<()> {
let mut builder = env_logger::Builder::from_default_env();
let env = env_logger::Env::default()
.default_filter_or("libparsec_platform_mountpoint=trace,fuser=trace");
let mut builder = env_logger::Builder::from_env(env);
// FIXME: This is a workaround to be able to get logs from libparsec
// Since electron seems to block stderr writes from libparsec.
// But only on unix system, on windows it works fine the logs are display on cmd.
Expand Down
128 changes: 7 additions & 121 deletions bindings/electron/src/meths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4767,18 +4767,6 @@ fn variant_entry_stat_js_to_rs<'a>(
}
}
};
let id = {
let js_val: Handle<JsString> = obj.get(cx, "id")?;
{
let custom_from_rs_string = |s: String| -> Result<libparsec::VlobID, _> {
libparsec::VlobID::from_hex(s.as_str()).map_err(|e| e.to_string())
};
match custom_from_rs_string(js_val.value(cx)) {
Ok(val) => val,
Err(err) => return cx.throw_type_error(err),
}
}
};
let parent = {
let js_val: Handle<JsString> = obj.get(cx, "parent")?;
{
Expand All @@ -4791,74 +4779,14 @@ fn variant_entry_stat_js_to_rs<'a>(
}
}
};
let created = {
let js_val: Handle<JsNumber> = obj.get(cx, "created")?;
{
let v = js_val.value(cx);
let custom_from_rs_f64 = |n: f64| -> Result<_, &'static str> {
libparsec::DateTime::from_timestamp_micros((n * 1_000_000f64) as i64)
.map_err(|_| "Out-of-bound datetime")
};
match custom_from_rs_f64(v) {
Ok(val) => val,
Err(err) => return cx.throw_type_error(err),
}
}
};
let updated = {
let js_val: Handle<JsNumber> = obj.get(cx, "updated")?;
{
let v = js_val.value(cx);
let custom_from_rs_f64 = |n: f64| -> Result<_, &'static str> {
libparsec::DateTime::from_timestamp_micros((n * 1_000_000f64) as i64)
.map_err(|_| "Out-of-bound datetime")
};
match custom_from_rs_f64(v) {
Ok(val) => val,
Err(err) => return cx.throw_type_error(err),
}
}
};
let base_version = {
let js_val: Handle<JsNumber> = obj.get(cx, "baseVersion")?;
{
let v = js_val.value(cx);
if v < (u32::MIN as f64) || (u32::MAX as f64) < v {
cx.throw_type_error("Not an u32 number")?
}
let v = v as u32;
v
}
};
let is_placeholder = {
let js_val: Handle<JsBoolean> = obj.get(cx, "isPlaceholder")?;
js_val.value(cx)
};
let need_sync = {
let js_val: Handle<JsBoolean> = obj.get(cx, "needSync")?;
js_val.value(cx)
};
let size = {
let js_val: Handle<JsNumber> = obj.get(cx, "size")?;
{
let v = js_val.value(cx);
if v < (u64::MIN as f64) || (u64::MAX as f64) < v {
cx.throw_type_error("Not an u64 number")?
}
let v = v as u64;
v
}
let base = {
let js_val: Handle<JsObject> = obj.get(cx, "base")?;
struct_file_stat_js_to_rs(cx, js_val)?
};
Ok(libparsec::EntryStat::File {
confinement_point,
id,
parent,
created,
updated,
base_version,
is_placeholder,
need_sync,
size,
base,
})
}
"EntryStatFolder" => {
Expand Down Expand Up @@ -4978,14 +4906,8 @@ fn variant_entry_stat_rs_to_js<'a>(
match rs_obj {
libparsec::EntryStat::File {
confinement_point,
id,
parent,
created,
updated,
base_version,
is_placeholder,
need_sync,
size,
base,
..
} => {
let js_tag = JsString::try_new(cx, "EntryStatFile").or_throw(cx)?;
Expand All @@ -5004,16 +4926,6 @@ fn variant_entry_stat_rs_to_js<'a>(
None => JsNull::new(cx).as_value(cx),
};
js_obj.set(cx, "confinementPoint", js_confinement_point)?;
let js_id = JsString::try_new(cx, {
let custom_to_rs_string =
|x: libparsec::VlobID| -> Result<String, &'static str> { Ok(x.hex()) };
match custom_to_rs_string(id) {
Ok(ok) => ok,
Err(err) => return cx.throw_type_error(err),
}
})
.or_throw(cx)?;
js_obj.set(cx, "id", js_id)?;
let js_parent = JsString::try_new(cx, {
let custom_to_rs_string =
|x: libparsec::VlobID| -> Result<String, &'static str> { Ok(x.hex()) };
Expand All @@ -5024,34 +4936,8 @@ fn variant_entry_stat_rs_to_js<'a>(
})
.or_throw(cx)?;
js_obj.set(cx, "parent", js_parent)?;
let js_created = JsNumber::new(cx, {
let custom_to_rs_f64 = |dt: libparsec::DateTime| -> Result<f64, &'static str> {
Ok((dt.as_timestamp_micros() as f64) / 1_000_000f64)
};
match custom_to_rs_f64(created) {
Ok(ok) => ok,
Err(err) => return cx.throw_type_error(err),
}
});
js_obj.set(cx, "created", js_created)?;
let js_updated = JsNumber::new(cx, {
let custom_to_rs_f64 = |dt: libparsec::DateTime| -> Result<f64, &'static str> {
Ok((dt.as_timestamp_micros() as f64) / 1_000_000f64)
};
match custom_to_rs_f64(updated) {
Ok(ok) => ok,
Err(err) => return cx.throw_type_error(err),
}
});
js_obj.set(cx, "updated", js_updated)?;
let js_base_version = JsNumber::new(cx, base_version as f64);
js_obj.set(cx, "baseVersion", js_base_version)?;
let js_is_placeholder = JsBoolean::new(cx, is_placeholder);
js_obj.set(cx, "isPlaceholder", js_is_placeholder)?;
let js_need_sync = JsBoolean::new(cx, need_sync);
js_obj.set(cx, "needSync", js_need_sync)?;
let js_size = JsNumber::new(cx, size as f64);
js_obj.set(cx, "size", js_size)?;
let js_base = struct_file_stat_rs_to_js(cx, base)?;
js_obj.set(cx, "base", js_base)?;
}
libparsec::EntryStat::Folder {
confinement_point,
Expand Down
60 changes: 28 additions & 32 deletions bindings/generator/api/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,33 @@ class InvalidManifest:
class Internal:
pass

class FileDescriptor(U32BasedType):
custom_from_rs_u32 = "|raw: u32| -> Result<_, String> { Ok(libparsec::FileDescriptor(raw)) }"
custom_to_rs_u32 = "|fd: libparsec::FileDescriptor| -> Result<_, &'static str> { Ok(fd.0) }"


class WorkspaceFdStatError(ErrorVariant):
class BadFileDescriptor:
pass

class Internal:
pass


class FileStat(Structure):
id: VlobID
created: DateTime
updated: DateTime
base_version: VersionInt
is_placeholder: bool
need_sync: bool
size: SizeInt


async def workspace_fd_stat(
workspace: Handle, fd: FileDescriptor
) -> Result[FileStat, WorkspaceFdStatError]:
raise NotImplementedError

class WorkspaceStatEntryError(ErrorVariant):
class Offline:
Expand Down Expand Up @@ -308,14 +335,8 @@ class Internal:
class EntryStat(Variant):
class File:
confinement_point: Optional[VlobID]
id: VlobID
parent: VlobID
created: DateTime
updated: DateTime
base_version: VersionInt
is_placeholder: bool
need_sync: bool
size: SizeInt
base: FileStat

class Folder:
confinement_point: Optional[VlobID]
Expand Down Expand Up @@ -467,10 +488,6 @@ class OpenOptions(Structure):
create_new: bool


class FileDescriptor(U32BasedType):
custom_from_rs_u32 = "|raw: u32| -> Result<_, String> { Ok(libparsec::FileDescriptor(raw)) }"
custom_to_rs_u32 = "|fd: libparsec::FileDescriptor| -> Result<_, &'static str> { Ok(fd.0) }"


class WorkspaceOpenFileError(ErrorVariant):
class Offline:
Expand Down Expand Up @@ -544,28 +561,7 @@ async def workspace_fd_close(
raise NotImplementedError


class WorkspaceFdStatError(ErrorVariant):
class BadFileDescriptor:
pass

class Internal:
pass


class FileStat(Structure):
id: VlobID
created: DateTime
updated: DateTime
base_version: VersionInt
is_placeholder: bool
need_sync: bool
size: SizeInt


async def workspace_fd_stat(
workspace: Handle, fd: FileDescriptor
) -> Result[FileStat, WorkspaceFdStatError]:
raise NotImplementedError


class WorkspaceFdFlushError(ErrorVariant):
Expand Down
Loading
Loading