|
6 | 6 | getFile, overwriteFile, getContentType,
|
7 | 7 | getPodUrlAll, deleteFile, getContainedResourceUrlAll, getSolidDataset,
|
8 | 8 | FetchError, UrlString,
|
9 |
| - getThing, getInteger, getDatetime |
| 9 | + getThing, getInteger, getDatetime, getDecimal |
10 | 10 | } from "@inrupt/solid-client";
|
11 | 11 | import BaseClient from './baseclient';
|
12 | 12 | import EventHandling from './eventhandling';
|
@@ -405,21 +405,19 @@ class Solid extends RemoteBase implements Remote, ConfigObserver {
|
405 | 405 |
|
406 | 406 | if (path.slice(-1) === '/') {
|
407 | 407 | return getSolidDataset(fileURL, { fetch: this.session.fetch }).then(containerDataset => {
|
| 408 | + console.log('container data set', containerDataset); |
408 | 409 | const URLs: UrlString[] = getContainedResourceUrlAll(containerDataset);
|
409 | 410 | const listing = URLs.reduce((map, item) => {
|
410 | 411 | const itemName = item.substring(fileURL.length);
|
411 |
| - const isFolder = itemName.slice(-1) === '/'; |
| 412 | + const fileDataset = getThing(containerDataset, item); |
| 413 | + map[itemName] = { |
| 414 | + 'ETag': getDecimal(fileDataset, 'http://www.w3.org/ns/posix/stat#mtime').toString(), |
| 415 | + 'Last-Modified': getDatetime(fileDataset, 'http://purl.org/dc/terms/modified').toUTCString(), // date.toUTCString() |
| 416 | + }; |
412 | 417 |
|
413 |
| - if (isFolder) { |
414 |
| - map[itemName] = { }; // We are skipping ETag |
415 |
| - } |
416 |
| - else { |
417 |
| - const fileDataset = getThing(containerDataset, item); |
418 |
| - |
419 |
| - map[itemName] = { |
420 |
| - 'Content-Length': getInteger(fileDataset, 'http://www.w3.org/ns/posix/stat#size'), |
421 |
| - 'Last-Modified': getDatetime(fileDataset, 'http://purl.org/dc/terms/modified').toUTCString(), // date.toUTCString() |
422 |
| - }; |
| 418 | + const isFolder = itemName.slice(-1) === '/'; |
| 419 | + if (!isFolder) { |
| 420 | + map[itemName]['Content-Length'] = getInteger(fileDataset, 'http://www.w3.org/ns/posix/stat#size'); |
423 | 421 | }
|
424 | 422 |
|
425 | 423 | return map;
|
@@ -447,10 +445,10 @@ class Solid extends RemoteBase implements Remote, ConfigObserver {
|
447 | 445 | });
|
448 | 446 | }
|
449 | 447 |
|
450 |
| - return getFile(fileURL, { fetch: this.session.fetch}).then(file => { |
| 448 | + return getFile(fileURL, { fetch: this.session.fetch}).then(async file => { |
451 | 449 | return {
|
452 | 450 | statusCode: 200,
|
453 |
| - body: file, |
| 451 | + body: await file.text(), |
454 | 452 | contentType: getContentType(file)
|
455 | 453 | } as RemoteResponse;
|
456 | 454 | }).catch(error => {
|
|
0 commit comments