Skip to content

Commit

Permalink
Fix: fixed error message for unauthorized access in listings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexagod committed Jan 6, 2025
1 parent c52e76c commit cdb34a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/commands/solid-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isDirectory, checkHeadersForAclAndMetadata, getResourceInfoFromDataset, getResourceInfoFromHeaders, ResourceInfo, getAclAndMetadata } from '../utils/util';
import { getContainedResourceUrlAll, getSolidDataset } from '@inrupt/solid-client';
import { getContainedResourceUrlAll, getSolidDataset, SolidDataset, WithServerResourceInfo } from '@inrupt/solid-client';
import { ICommandOptions, setOptionDefaults } from './solid-command';

export interface ICommandOptionsList extends ICommandOptions{
Expand All @@ -14,8 +14,20 @@ export default async function list(url: string, options?: ICommandOptionsList) {
commandOptions.logger.error('List can only be called on containers. Please write containers with their trailing slash.')
throw new Error('List can only be called on containers.');
}
let dataset = await getSolidDataset(url, { fetch: commandOptions.fetch })
let containedResources = getContainedResourceUrlAll(dataset)

// let dataset = await getSolidDataset(url, { fetch: commandOptions.fetch })
// let containedResources = getContainedResourceUrlAll(dataset)

let dataset: SolidDataset & WithServerResourceInfo;
let containedResources: string[];

try {
dataset = await getSolidDataset(url, { fetch: commandOptions.fetch })
containedResources = getContainedResourceUrlAll(dataset)
} catch (e) {
throw new Error(`Resource at ${url} does not exist or unauthorized to access resource.`)
}

let resourceInfos : ResourceInfo[] = []

// Test original directory for acl file
Expand Down
2 changes: 1 addition & 1 deletion src/shell/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ListCommand extends SolidCommand {
url = await changeUrlPrefixes(authenticationInfo, url)
listings = await list(url, options)
} catch (e) {
writeErrorString(`Could not provide listing for ${url}`, e, options)
writeErrorString(`Could not provide listing for ${url}`, (e as Error).message, options)
if (this.mayExit) process.exit(1)
}
// Output to command line
Expand Down

0 comments on commit cdb34a1

Please sign in to comment.