@samitouri / QOSami-HFS / commits / cddb694c

fix: Windows' "add to hfs" failed sometimes

Massimo Melina committed Oct 5, 2024 at 19:05 UTC cddb694c26e281b407e4eb64c7385083e9b98fd4
1 file changed +2 -2
src/api.vfs.ts
+2 -2
@@ -233,12 +233,12 @@ const apis: ApiHandlers = {
233 const url = h.srv!.name + '://localhost:' + h.port
234 for (const k of ['*', 'Directory']) {
235 await reg('add', WINDOWS_REG_KEY.replace('*', k), '/ve', '/f', '/d', 'Add to HFS (new)')
236 - await reg('add', WINDOWS_REG_KEY.replace('*', k) + '\\command', '/ve', '/f', '/d', `powershell -Command "
236 + await reg('add', WINDOWS_REG_KEY.replace('*', k) + '\\command', '/ve', '/f', '/d', `powershell -WindowStyle Hidden -Command "
237 $wsh = New-Object -ComObject Wscript.Shell;
238 $j = @{parent=@'\n${parent}\n'@; source=@'\n%1\n'@} | ConvertTo-Json -Compress
239 $j = [System.Text.Encoding]::UTF8.GetBytes($j);
240 try {
241 - $res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 1 -Body $j;
241 + $res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 2 -Body $j;
242 $json = $res.Content | ConvertFrom-Json; $link = $json.link; $link | Set-Clipboard;
243 $wsh.Popup('The link is ready to be pasted');
244 } catch { $wsh.Popup('Server is down', 0, 'Error', 16); }"`)