groove-dev 0.27.154 → 0.27.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/routes/files.js +26 -4
- package/node_modules/@groove-dev/daemon/src/tunnel-manager.js +0 -2
- package/node_modules/@groove-dev/gui/dist/assets/{index-BTLb6zTD.js → index-COQYX12F.js} +2 -2
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/src/components/agents/agent-file-tree.jsx +12 -14
- package/node_modules/@groove-dev/gui/src/components/editor/file-tree.jsx +6 -8
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/routes/files.js +26 -4
- package/packages/daemon/src/tunnel-manager.js +0 -2
- package/packages/gui/dist/assets/{index-BTLb6zTD.js → index-COQYX12F.js} +2 -2
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +1 -1
- package/packages/gui/src/components/agents/agent-file-tree.jsx +12 -14
- package/packages/gui/src/components/editor/file-tree.jsx +6 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// FSL-1.1-Apache-2.0 — see LICENSE
|
|
2
2
|
import { resolve, sep, isAbsolute, basename } from 'path';
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync, mkdirSync, unlinkSync, renameSync, rmSync, createReadStream, realpathSync } from 'fs';
|
|
4
|
-
import { execFile, execFileSync } from 'child_process';
|
|
4
|
+
import { execFile, execFileSync, spawn } from 'child_process';
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { lookup as mimeLookup } from '../mimetypes.js';
|
|
7
7
|
|
|
@@ -331,15 +331,37 @@ export function registerFileRoutes(app, daemon) {
|
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
333
|
|
|
334
|
-
// Download a file (
|
|
334
|
+
// Download a file or folder (folders are streamed as zip)
|
|
335
335
|
app.get('/api/files/download', (req, res) => {
|
|
336
336
|
const relPath = req.query.path;
|
|
337
337
|
const result = validateFilePath(relPath, getEditorRoot(daemon));
|
|
338
338
|
if (result.error) return res.status(400).json({ error: result.error });
|
|
339
|
-
if (!existsSync(result.fullPath)) return res.status(404).json({ error: '
|
|
339
|
+
if (!existsSync(result.fullPath)) return res.status(404).json({ error: 'Not found' });
|
|
340
340
|
|
|
341
341
|
const stat = statSync(result.fullPath);
|
|
342
|
-
|
|
342
|
+
|
|
343
|
+
if (stat.isDirectory()) {
|
|
344
|
+
const folderName = basename(result.fullPath);
|
|
345
|
+
res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(folderName)}.zip"`);
|
|
346
|
+
res.setHeader('Content-Type', 'application/zip');
|
|
347
|
+
|
|
348
|
+
const zipProc = spawn('zip', [
|
|
349
|
+
'-r', '-q', '-',
|
|
350
|
+
relPath,
|
|
351
|
+
'-x', `${relPath}/.git/*`,
|
|
352
|
+
'-x', `${relPath}/node_modules/*`,
|
|
353
|
+
], {
|
|
354
|
+
cwd: getEditorRoot(daemon),
|
|
355
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
zipProc.stdout.pipe(res);
|
|
359
|
+
zipProc.stderr.on('data', () => {});
|
|
360
|
+
zipProc.on('error', () => {
|
|
361
|
+
if (!res.headersSent) res.status(500).json({ error: 'Failed to create zip' });
|
|
362
|
+
});
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
343
365
|
|
|
344
366
|
const name = basename(result.fullPath);
|
|
345
367
|
const mime = mimeLookup(name) || 'application/octet-stream';
|
|
@@ -267,8 +267,6 @@ export class TunnelManager {
|
|
|
267
267
|
let testResult;
|
|
268
268
|
if (opts.skipTest && opts.testResult) {
|
|
269
269
|
testResult = opts.testResult;
|
|
270
|
-
} else if (config.lastConnected && opts.skipTest !== false) {
|
|
271
|
-
testResult = { reachable: true, daemonRunning: true, grooveInstalled: true, remoteVersion: null };
|
|
272
270
|
} else {
|
|
273
271
|
testResult = await this.test(id);
|
|
274
272
|
}
|