Skip to content

Commit

Permalink
fixed remote files #633
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 11, 2024
1 parent 41f8f52 commit 2862d1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Go to the `v1` branch to see the changelog of Lume 1.

## [2.2.4] - Unreleased
### Fixed
- Reload remote files [#633].
- Vento components must be sync.
- Updated dependencies: `std`, `terser`, `sass`, `xml`, `liquid`, `highlight.js`, `unocss`, `decap_cms`.
- Use a pinned version of `npm:decap-server` package for stability.
- DecapCMS script: switch from `unpkg` to `jsDelivr` for performance.


## [2.2.3] - 2024-07-05
### Added
- New option `caseSensitiveUrls` to allow to export two urls with the same name but different cases [#625].
Expand Down Expand Up @@ -442,6 +442,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
[#621]: https://github.com/lumeland/lume/issues/621
[#625]: https://github.com/lumeland/lume/issues/625
[#630]: https://github.com/lumeland/lume/issues/630
[#633]: https://github.com/lumeland/lume/issues/633

[2.2.4]: https://github.com/lumeland/lume/compare/v2.2.3...HEAD
[2.2.3]: https://github.com/lumeland/lume/compare/v2.2.2...v2.2.3
Expand Down
16 changes: 8 additions & 8 deletions core/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ export class Entry {
this.src = src;
}

removeCache() {
this.#content.clear();
this.#info = undefined;
this.flags.clear();
}

getContent(loader: Loader): Promise<RawData> | RawData {
if (!this.#content.has(loader)) {
this.#content.set(loader, loader(this.src));
Expand Down Expand Up @@ -73,7 +67,8 @@ export default class FS {
/** Update the entry and returns it if it was removed */
update(path: string): Entry | undefined {
const exist = this.entries.get(path);
const entry = exist || this.addEntry({ path });
this.entries.delete(path);
const entry = this.addEntry({ path });

// New directory, walk it
if (!exist && entry.type === "directory") {
Expand All @@ -82,11 +77,16 @@ export default class FS {
}

try {
entry.removeCache();
entry.getInfo();
} catch (error) {
// Remove if it doesn't exist
if (error instanceof Deno.errors.NotFound) {
const src = this.remoteFiles.get(path);
if (src) {
entry.flags.add("remote");
entry.src = src;
return;
}
this.removeEntry(path);
return exist;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/core/scopes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ Deno.test("Scripts", async (t) => {
equals(entry.flags.size, 0);
entry.flags.add("foo");
equals(entry.flags.size, 1);
entry.removeCache();
equals(entry.flags.size, 0);
});

await t.step("Add scopes", () => {
Expand Down

0 comments on commit 2862d1e

Please sign in to comment.