Skip to content

Commit 131e085

Browse files
committed
fix(plugins): streamline SR model downloading via zip packages and update plugin version to 0.1.0
1 parent 58c0534 commit 131e085

12 files changed

Lines changed: 1455 additions & 771 deletions

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ set_target_properties(sr_realesrgan_d3d11 PROPERTIES
388388
)
389389
target_include_directories(sr_realesrgan_d3d11 PRIVATE QuickView)
390390
target_link_libraries(sr_realesrgan_d3d11 PRIVATE d3d11.lib d3dcompiler.lib dxgi.lib shlwapi.lib)
391+
add_dependencies(QuickView sr_realesrgan_d3d11)
391392

392393
# ============================================================================
393394
# Unit Tests

‎QuickView/AppStrings.cpp‎

Lines changed: 52 additions & 19 deletions
Large diffs are not rendered by default.

‎QuickView/AppStrings.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ namespace AppStrings {
478478
extern const wchar_t* Export_Checkbox_SuperResolution;
479479
extern const wchar_t* Settings_Label_SrDebounce;
480480
extern const wchar_t* Settings_Tooltip_SrDebounce;
481+
extern const wchar_t* Settings_Header_PluginTriggers;
481482
extern const wchar_t* Settings_Header_PluginParams;
483+
extern const wchar_t* Settings_Label_SrStorageFolder;
484+
extern const wchar_t* Settings_Button_OpenModelFolder;
485+
extern const wchar_t* Settings_Prompt_DownloadModelFirst;
482486
extern const wchar_t* Settings_Label_SrSharpness;
483487
extern const wchar_t* Settings_Tooltip_SrSharpness;
484488
extern const wchar_t* Settings_Label_SrDenoise;

‎QuickView/ArchiveVFS.cpp‎

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,21 @@ namespace QuickView {
5454
void (*progressCb)(float progress, void* userData),
5555
void* userData
5656
) {
57+
char logBuf[512];
58+
sprintf_s(logBuf, "[QVX-Extract] ExtractZipToDirectory: opening '%ls' -> '%ls'\n", zipPath.c_str(), destDir.c_str());
59+
OutputDebugStringA(logBuf);
60+
5761
ZipArchive zip(zipPath);
58-
if (!zip.IsValid()) return false;
62+
if (!zip.IsValid()) {
63+
sprintf_s(logBuf, "[QVX-Extract] Failed: zip.IsValid() is false for '%ls'\n", zipPath.c_str());
64+
OutputDebugStringA(logBuf);
65+
return false;
66+
}
5967

6068
size_t totalEntries = zip.GetEntryCount();
69+
sprintf_s(logBuf, "[QVX-Extract] Zip has %zu entries\n", totalEntries);
70+
OutputDebugStringA(logBuf);
71+
6172
if (totalEntries == 0) return true;
6273

6374
EnsureParentDirectory(destDir + L"\\dummy.tmp");
@@ -78,21 +89,37 @@ namespace QuickView {
7889
}
7990

8091
::std::wstring outPath = destDir + L"\\" + relName;
92+
if (relName.back() == L'\\') {
93+
EnsureParentDirectory(outPath + L"\\dummy.tmp");
94+
continue;
95+
}
8196
EnsureParentDirectory(outPath);
8297

8398
const ArchiveEntry& entry = zip.GetEntry(i);
99+
sprintf_s(logBuf, "[QVX-Extract] Entry [%zu]: '%ls', uncompSize=%u, method=%u\n", i, relName.c_str(), entry.uncompSize, entry.method);
100+
OutputDebugStringA(logBuf);
101+
84102
if (buffer.size() < entry.uncompSize) {
85103
buffer.resize(entry.uncompSize);
86104
}
87105

88106
size_t extractedSize = zip.ExtractEntry(i, buffer.data(), buffer.size());
89107
if (extractedSize != entry.uncompSize) {
108+
sprintf_s(logBuf, "[QVX-Extract] ExtractEntry failed for '%ls' (got %zu, expected %u)\n", relName.c_str(), extractedSize, entry.uncompSize);
109+
OutputDebugStringA(logBuf);
90110
return false;
91111
}
92112

93-
HANDLE hFile = CreateFileW(outPath.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
113+
SetFileAttributesW(outPath.c_str(), FILE_ATTRIBUTE_NORMAL);
114+
HANDLE hFile = CreateFileW(outPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
94115
if (hFile == INVALID_HANDLE_VALUE) {
95-
return false;
116+
DeleteFileW(outPath.c_str());
117+
hFile = CreateFileW(outPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
118+
if (hFile == INVALID_HANDLE_VALUE) {
119+
sprintf_s(logBuf, "[QVX-Extract] CreateFileW failed for '%ls' (err=%lu)\n", outPath.c_str(), GetLastError());
120+
OutputDebugStringA(logBuf);
121+
return false;
122+
}
96123
}
97124

98125
DWORD written = 0;
@@ -103,6 +130,8 @@ namespace QuickView {
103130
CloseHandle(hFile);
104131

105132
if (!writeOk || written != entry.uncompSize) {
133+
sprintf_s(logBuf, "[QVX-Extract] WriteFile failed for '%ls' (written=%lu, expected=%u, err=%lu)\n", outPath.c_str(), written, entry.uncompSize, GetLastError());
134+
OutputDebugStringA(logBuf);
106135
DeleteFileW(outPath.c_str());
107136
return false;
108137
}
@@ -113,6 +142,8 @@ namespace QuickView {
113142
}
114143
}
115144

145+
sprintf_s(logBuf, "[QVX-Extract] ExtractZipToDirectory completed successfully for '%ls'\n", zipPath.c_str());
146+
OutputDebugStringA(logBuf);
116147
return true;
117148
}
118149

@@ -290,12 +321,19 @@ namespace QuickView {
290321
if (inflateInit2(m_zstream.get(), -MAX_WBITS) != Z_OK) return 0;
291322
m_zstream_init = true;
292323
} else {
293-
if (inflateReset(m_zstream.get()) != Z_OK) return 0;
324+
if (inflateReset(m_zstream.get()) != Z_OK) {
325+
inflateEnd(m_zstream.get());
326+
if (inflateInit2(m_zstream.get(), -MAX_WBITS) != Z_OK) return 0;
327+
}
294328
}
295329

296330
int ret = inflate(m_zstream.get(), Z_FINISH);
297331

298-
if (ret != Z_STREAM_END && ret != Z_OK) return 0;
332+
if (ret != Z_STREAM_END && ret != Z_OK) {
333+
inflateEnd(m_zstream.get());
334+
m_zstream_init = false;
335+
return 0;
336+
}
299337
} else {
300338
// Unsupported compression method
301339
return false;

0 commit comments

Comments
 (0)