Let a sync window take a whole share in one click

The window editor is path-first, which is exact but slow for the case that is nearly all of them.
The chips only offer whole shares; a subpath already in the window marks its share partial rather
than offering to widen it, and the path box stays the only way to express a subpath or a profile.
This commit is contained in:
Gmer4Lfe
2026-08-23 17:16:24 -04:00
parent fbf2b92167
commit 28987240aa
2 changed files with 115 additions and 0 deletions
+32
View File
@@ -91,6 +91,38 @@ require_once dirname(__DIR__) . '/include/monitor.php';
// ── Live sync log ─────────────────────────────────────────────────────────────
$action = $_GET['action'] ?? '';
// ── Share list, for the quick-select strip on the window editor ──────────────────────────────
// The editor is path-first — type or browse, then Add — which is exact but slow for the case that
// is nearly all of them: add one whole share. This answers "what shares exist here", so the strip
// can offer them as one click each.
//
// Read from /boot/config/shares/*.cfg rather than by listing /mnt/user, because a share is a
// declared thing: the directory can be absent on a share that has never been written to, and
// listing the mount would also invent entries for stray directories that are not shares at all.
if ($action === 'shares') {
$out = [];
foreach (glob('/boot/config/shares/*.cfg') ?: [] as $cfg) {
$name = basename($cfg, '.cfg');
$raw = (string) @file_get_contents($cfg);
$get = function (string $k) use ($raw): string {
return preg_match('/^' . $k . '="([^"]*)"/m', $raw, $m) ? $m[1] : '';
};
$path = '/mnt/user/' . $name;
$out[] = [
'name' => $name,
'path' => $path,
'comment' => $get('shareComment'),
'pool' => $get('shareCachePool'),
'cache' => $get('shareUseCache'),
// Present is not the same as declared — a share can exist in conf with no directory yet.
'exists' => is_dir($path),
];
}
usort($out, fn($a, $b) => strcasecmp($a['name'], $b['name']));
header('Content-Type: application/json');
echo json_encode(['ok' => true, 'shares' => $out]);
exit;
}
if ($action === 'rsync_log') {
$lockDir = '/tmp/unraid_locks';
$lines = [];