Skip to content

Conversation

@gedeondoescode
Copy link
Contributor

The daemon now successfully builds and runs on Windows. A few miscellaneous changes.

Things to note:

  • Indexing does not work at the moment. Database ops for jobs never occur when they should, because the job ID is not made available immediately.
  • It's possible that reopening the same library duplicates the device on the frontend. Something similar occurred with the volumes, so maybe a similar fix is needed.

Closes N/A

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
Copy link
Contributor

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).

Suggested change
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| {
Copy link
Contributor

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.

Suggested change
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();
Copy link
Contributor

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.

Suggested change
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());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant