From 863209c67d6fe3cce2ae8a6b0346ec4dbda286da Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 25 Jul 2023 09:20:59 -0500 Subject: respect remote file management option in UI --- src/web/src/components/System/Files/Explorer.js | 45 +++++++++++++------------ src/web/src/components/System/Files/index.js | 8 +++-- src/web/src/components/System/System.js | 2 +- 3 files changed, 29 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/web/src/components/System/Files/Explorer.js b/src/web/src/components/System/Files/Explorer.js index 093192bf..77b2f958 100644 --- a/src/web/src/components/System/Files/Explorer.js +++ b/src/web/src/components/System/Files/Explorer.js @@ -11,7 +11,7 @@ import { list, deleteDirectory, deleteFile } from '../../../lib/files'; import { formatBytes, formatDate } from '../../../lib/util'; import { LoaderSegment } from '../../Shared'; -const Explorer = ({ root }) => { +const Explorer = ({ root, remoteFileManagement }) => { const [directory, setDirectory] = useState({ files: [], directories: [] }); const [subdirectory, setSubdirectory] = useState([]); const [loading, setLoading] = useState(false); @@ -46,27 +46,28 @@ const Explorer = ({ root }) => { {modifiedAt ? formatDate(modifiedAt) : ''} {length ? formatBytes(length) : ''} - - } - centered - size='small' - header={
} - content={`Are you sure you want to delete file '${fullName}'?`} - actions={[ - 'Cancel', - { - key: 'done', - content: 'Delete', - negative: true, - onClick: async () => { - await deleteFile({ root, path: `${subdirectory.join('/')}/${fullName}`}); - fetch(); + {remoteFileManagement + ? + } + centered + size='small' + header={
} + content={`Are you sure you want to delete file '${fullName}'?`} + actions={[ + 'Cancel', + { + key: 'done', + content: 'Delete', + negative: true, + onClick: async () => { + await deleteFile({ root, path: `${subdirectory.join('/')}/${fullName}`}); + fetch(); + }, }, - }, - ]} - /> + ]}/> + : <>} ; @@ -84,7 +85,7 @@ const Explorer = ({ root }) => { {modifiedAt ? formatDate(modifiedAt) : ''} - {deletable + {remoteFileManagement && deletable ? diff --git a/src/web/src/components/System/Files/index.js b/src/web/src/components/System/Files/index.js index cf3dc869..a7a90aba 100644 --- a/src/web/src/components/System/Files/index.js +++ b/src/web/src/components/System/Files/index.js @@ -4,17 +4,19 @@ import { Tab } from 'semantic-ui-react'; import './Files.css'; import Explorer from './Explorer'; -const Files = () => { +const Files = ({ options } = {}) => { + const { remoteFileManagement } = options; + const panes = [ { route: 'downloads', menuItem: 'Downloads', - render: () => , + render: () => , }, { route: 'incomplete', menuItem: 'Incomplete', - render: () => , + render: () => , }, ]; diff --git a/src/web/src/components/System/System.js b/src/web/src/components/System/System.js index 3629082e..2baba767 100644 --- a/src/web/src/components/System/System.js +++ b/src/web/src/components/System/System.js @@ -59,7 +59,7 @@ const System = ({ state = {}, theme, options = {} }) => { icon: 'folder open', content: 'Files', }, - render: () => , + render: () => , }, { route: 'data', -- cgit v1.2.3 From 337e47b84b3456ab402c5b49d6811e7ad2cafc0b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 25 Jul 2023 09:21:20 -0500 Subject: fix crash validating shares --- src/slskd/Core/Options.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index c438c03c..2ee21733 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -652,17 +652,19 @@ namespace slskd { var results = new List(); + var directories = Directories ?? Enumerable.Empty(); + bool IsBlankPath(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])$"); - Directories.Where(share => IsBlankPath(share)).ToList() + directories?.Where(share => IsBlankPath(share)).ToList() .ForEach(blank => results.Add(new ValidationResult($"Share {blank} doees not specify a path"))); bool IsRootMount(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])/$"); - Directories.Where(share => IsRootMount(share)).ToList() + directories?.Where(share => IsRootMount(share)).ToList() .ForEach(blank => results.Add(new ValidationResult($"Share {blank} specifies a root mount, which is not supported."))); // starts with '/', 'X:', or '\\' bool IsAbsolutePath(string share) => Regex.IsMatch(share.LocalizePath(), @"^(!|-){0,1}(\[.*\])?(\/|[a-zA-Z]:|\\\\).*$"); - Directories.Where(share => !IsAbsolutePath(share)).ToList() + directories?.Where(share => !IsAbsolutePath(share)).ToList() .ForEach(relativePath => results.Add(new ValidationResult($"Share {relativePath} contains a relative path; only absolute paths are supported."))); (string Raw, string Alias, string Path) Digest(string share) @@ -677,7 +679,7 @@ namespace slskd return (share, share.Split(new[] { '/', '\\' }).Last(), share); } - var digestedShared = Directories + var digestedShared = directories .Select(share => Digest(share.TrimEnd('/', '\\'))) .ToHashSet(); -- cgit v1.2.3