mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 15:17:09 +00:00
Fix root hashing due to missing root dirs
This commit is contained in:
@@ -33,9 +33,10 @@ export function ProjectCreation() {
|
||||
}
|
||||
}
|
||||
|
||||
const onCreate = useCallback(() => {
|
||||
const onCreate = useCallback(async () => {
|
||||
setCreating(true)
|
||||
const rootUri = `${PROJECTS_URI}${hexId()}/`
|
||||
await client.fs.mkdir(rootUri)
|
||||
createProject({ name, namespace, version, storage: { type: 'indexeddb', rootUri } })
|
||||
changeProject(name)
|
||||
if (file) {
|
||||
|
||||
@@ -32,7 +32,7 @@ export function ProjectPanel() {
|
||||
}
|
||||
service.watchTree(projectRoot, setEntries)
|
||||
client.fs.readdir(projectRoot).then(entries => {
|
||||
setEntries(entries.flatMap(e => e.name.startsWith(projectRoot) ? [e.name.slice(projectRoot.length)] : []))
|
||||
setEntries(entries.flatMap(e => e.isFile() && e.name.startsWith(projectRoot) ? [e.name.slice(projectRoot.length)] : []))
|
||||
})
|
||||
return () => service.unwatchTree(projectRoot, setEntries)
|
||||
}, [service, projectRoot])
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ComponentChildren } from 'preact'
|
||||
import { createContext } from 'preact'
|
||||
import { useCallback, useContext, useEffect, useMemo, useState } from 'preact/hooks'
|
||||
import type { VersionId } from '../services/index.js'
|
||||
import { ROOT_URI, SpyglassClient } from '../services/Spyglass.js'
|
||||
import { DRAFTS_URI, SpyglassClient } from '../services/Spyglass.js'
|
||||
import { Store } from '../Store.js'
|
||||
|
||||
export type ProjectMeta = {
|
||||
@@ -37,7 +37,7 @@ export const DRAFT_PROJECT: ProjectMeta = {
|
||||
namespace: 'draft',
|
||||
storage: {
|
||||
type: 'indexeddb',
|
||||
rootUri: `${ROOT_URI}drafts/`,
|
||||
rootUri: DRAFTS_URI,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ export const ROOT_URI = 'file:///root/'
|
||||
export const DEPENDENCY_URI = `${ROOT_URI}dependency/`
|
||||
export const UNSAVED_URI = `${ROOT_URI}unsaved/`
|
||||
export const PROJECTS_URI = `${ROOT_URI}projects/`
|
||||
export const DRAFTS_URI = `${ROOT_URI}drafts/`
|
||||
|
||||
const INITIAL_DIRS = [CACHE_URI, ROOT_URI, DEPENDENCY_URI, UNSAVED_URI, PROJECTS_URI, DRAFTS_URI]
|
||||
|
||||
const builtinMcdoc = `
|
||||
use ::java::server::util::text::Text
|
||||
@@ -169,8 +172,6 @@ export class SpyglassService {
|
||||
}
|
||||
await this.service.project.externals.fs.writeFile(newUri, content)
|
||||
await this.service.project.externals.fs.unlink(oldUri)
|
||||
// await this.service.project.externals.fs.writeFile(oldUri, content)
|
||||
// await this.service.project.externals.fs.unlink(oldUri)
|
||||
const d = this.client.documents.get(oldUri)
|
||||
if (d) {
|
||||
const doc = TextDocument.create(newUri, d.doc.languageId, d.doc.version, d.doc.getText())
|
||||
@@ -261,6 +262,7 @@ export class SpyglassService {
|
||||
}
|
||||
|
||||
public static async create(versionId: VersionId, client: SpyglassClient) {
|
||||
await Promise.allSettled(INITIAL_DIRS.map(async uri => client.externals.fs.mkdir(uri)))
|
||||
const version = siteConfig.versions.find(v => v.id === versionId)!
|
||||
const logger = console
|
||||
const service = new core.Service({
|
||||
|
||||
Reference in New Issue
Block a user