Skip to content

Commit cf85029

Browse files
committed
feat: implement office thumbnail provider with COM interop and fix Explorer thumbnail issues
1 parent 0916570 commit cf85029

7 files changed

Lines changed: 494 additions & 559 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/core/src/lib.rs

Lines changed: 182 additions & 242 deletions
Large diffs are not rendered by default.

crates/windows-dll/src/dll.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ impl IClassFactory_Impl for ClassFactory {
5151
if punkouter.is_some() {
5252
return CLASS_E_NOAGGREGATION.ok();
5353
}
54-
self.provider.create_instance(riid, ppvobject)
54+
let res = self.provider.create_instance(riid, ppvobject);
55+
if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(&temp_log) {
56+
let _ = writeln!(file, "[DLL] [PID:{}] ClassFactory::CreateInstance result: {:?}", std::process::id(), res);
57+
}
58+
res
5559
}
5660

5761
fn LockServer(&self, _flock: BOOL) -> windows::core::Result<()> {

crates/windows/src/providers/office_provider.rs

Lines changed: 108 additions & 168 deletions
Large diffs are not rendered by default.

crates/windows/src/providers/thumbnail_file.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl IThumbnailProvider_Impl for ThumbnailFileHandler {
302302
}
303303
}
304304

305-
// Create lock file
305+
// Create lock file (with current PID initially, will be updated with child PID if spawn succeeds)
306306
if let Ok(mut f) = std::fs::File::create(&lock_file) {
307307
let _ = write!(f, "PID: {}", std::process::id());
308308
}
@@ -330,14 +330,14 @@ impl IThumbnailProvider_Impl for ThumbnailFileHandler {
330330
.arg("--api").arg("default")
331331
.arg("--lock-file").arg(&lock_file);
332332

333-
// if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(&temp_log) {
334-
// let _ = writeln!(file, "[ThumbnailFileHandler] [PID:{}] Spawning Async CLI: {:?} -> {:?}", std::process::id(), cli_path, cache_file);
335-
// }
336-
337333
// Spawn async
338334
match cmd.spawn() {
339-
Ok(_) => {
340-
log_debug("CLI process spawned successfully. Returning E_PENDING.");
335+
Ok(child) => {
336+
// Update lock file with CLI process PID for better liveness tracking
337+
if let Ok(mut f) = std::fs::File::create(&lock_file) {
338+
let _ = write!(f, "PID: {}", child.id());
339+
}
340+
log_debug(&format!("CLI process spawned successfully (PID: {}). Returning E_PENDING.", child.id()));
341341
return Err(windows::core::Error::from(E_PENDING));
342342
},
343343
Err(e) => {

tools/step2obj.bat

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22
setlocal EnableDelayedExpansion
3-
chcp 65001 >nul
3+
REM chcp 65001 >nul
44

55
REM Generate a unique log file for this execution
66
if defined STEP2OBJ_OUTPUT (
@@ -10,39 +10,39 @@ if defined STEP2OBJ_OUTPUT (
1010
)
1111

1212
set SCRIPT_DIR=%~dp0
13-
echo [step2obj] Starting in %SCRIPT_DIR% > "!LOG_FILE!"
14-
echo [step2obj] Input: %STEP2OBJ_INPUT% >> "!LOG_FILE!"
15-
echo [step2obj] Output: %STEP2OBJ_OUTPUT% >> "!LOG_FILE!"
16-
echo [step2obj] Date: %DATE% %TIME% >> "!LOG_FILE!"
13+
echo [step2obj] Starting in %SCRIPT_DIR%
14+
echo [step2obj] Input: %STEP2OBJ_INPUT%
15+
echo [step2obj] Output: %STEP2OBJ_OUTPUT%
16+
echo [step2obj] Date: %DATE% %TIME%
1717

1818
REM Check for python command
19-
where python >> "!LOG_FILE!" 2>&1
20-
python --version >> "!LOG_FILE!" 2>&1
19+
where python
20+
python --version
2121

2222
REM Use local Embedded Python (Plan A)
2323
if exist "%SCRIPT_DIR%python\python.exe" (
24-
echo [step2obj] Using local python >> "!LOG_FILE!"
24+
echo [step2obj] Using local python
2525
set PYTHONIOENCODING=utf-8
26-
"%SCRIPT_DIR%python\python.exe" -u "%SCRIPT_DIR%step2obj_occ.py" %* >> "!LOG_FILE!" 2>&1
26+
"%SCRIPT_DIR%python\python.exe" -u "%SCRIPT_DIR%step2obj_occ.py" %*
2727
set EXIT_CODE=!ERRORLEVEL!
2828
goto :END
2929
)
3030

3131
REM Use System Python (Plan B - Explicit Path)
3232
if exist "C:\Users\Shomn\AppData\Local\Programs\Python\Python311\python.exe" (
33-
echo [step2obj] Using explicit python path >> "!LOG_FILE!"
33+
echo [step2obj] Using explicit python path
3434
set PYTHONIOENCODING=utf-8
35-
"C:\Users\Shomn\AppData\Local\Programs\Python\Python311\python.exe" -u "%SCRIPT_DIR%step2obj_occ.py" %* >> "!LOG_FILE!" 2>&1
35+
"C:\Users\Shomn\AppData\Local\Programs\Python\Python311\python.exe" -u "%SCRIPT_DIR%step2obj_occ.py" %*
3636
set EXIT_CODE=!ERRORLEVEL!
3737
goto :END
3838
)
3939

4040
REM Use System Python (Plan C - PATH)
4141
where python >nul 2>nul
4242
if !ERRORLEVEL! equ 0 (
43-
echo [step2obj] Using system python >> "!LOG_FILE!"
43+
echo [step2obj] Using system python
4444
set PYTHONIOENCODING=utf-8
45-
python -u "%SCRIPT_DIR%step2obj_occ.py" %* >> "!LOG_FILE!" 2>&1
45+
python -u "%SCRIPT_DIR%step2obj_occ.py" %*
4646
set EXIT_CODE=!ERRORLEVEL!
4747
goto :END
4848
)
@@ -51,5 +51,5 @@ echo [step2obj.bat] Error: No Python environment found! >> "!LOG_FILE!"
5151
set EXIT_CODE=1
5252

5353
:END
54-
echo [step2obj] Exit Code: !EXIT_CODE! >> "!LOG_FILE!"
54+
echo [step2obj] Exit Code: !EXIT_CODE! >> "%LOG_FILE%"
5555
exit /b !EXIT_CODE!

0 commit comments

Comments
 (0)