-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable Spacedrive to successfully build on Windows #3003
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
base: main
Are you sure you want to change the base?
Conversation
| inode: Set(inode.map(|i| i as i64)), // Use extracted inode | ||
| parent_id: Set(None), // Location root has no parent | ||
| volume_id: Set(Some(volume_id)), // Volume is required for all locations | ||
| inode: Set(inode.map(|i: i64| i as i64)), // Use extracted inode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like inode is Option<u64> above; |i: i64| i as i64 seems like it won't compile (and a plain as cast here can truncate on overflow).
| inode: Set(inode.map(|i: i64| i as i64)), // Use extracted inode | |
| inode: Set(inode.and_then(|i| i.try_into().ok())), // Use extracted inode |
| }; | ||
|
|
||
| // Open file to get handle for GetFileInformationByHandle | ||
| std::fs::File::open(location_root_path).ok().and_then(|file| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
location_root_path is a directory; File::open can fail on Windows unless you open with FILE_FLAG_BACKUP_SEMANTICS, which would make this always return None.
| std::fs::File::open(location_root_path).ok().and_then(|file| { | |
| // Open directory to get handle for GetFileInformationByHandle | |
| use std::os::windows::fs::OpenOptionsExt; | |
| use windows_sys::Win32::Foundation::HANDLE; | |
| use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_BACKUP_SEMANTICS; | |
| std::fs::OpenOptions::new() | |
| .read(true) | |
| .custom_flags(FILE_FLAG_BACKUP_SEMANTICS) | |
| .open(location_root_path) | |
| .ok() | |
| .and_then(|file| { | |
| let mut info: BY_HANDLE_FILE_INFORMATION = unsafe { std::mem::zeroed() }; | |
| let success = unsafe { | |
| GetFileInformationByHandle(file.as_raw_handle() as HANDLE, &mut info) | |
| }; | |
| if success != 0 { | |
| Some(((info.nFileIndexHigh as u64) << 32) | (info.nFileIndexLow as u64)) | |
| } else { | |
| None | |
| } | |
| }) |
| // This would require adding serde_json dependency | ||
| warn!("PowerShell JSON parsing not fully implemented yet"); | ||
| Ok(Vec::new()) | ||
| let trimmed = json_output.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConvertTo-Json can emit null (eg when no objects are returned), which would currently hard-error on the object parse path. Treating that as empty keeps volume detection resilient.
| let trimmed = json_output.trim(); | |
| let trimmed = json_output.trim(); | |
| if trimmed.is_empty() || trimmed == "null" { | |
| debug!("PowerShell returned empty/null output"); | |
| return Ok(Vec::new()); | |
| } |
The daemon now successfully builds and runs on Windows. A few miscellaneous changes.
Things to note:
Closes N/A