载入中...
搜索中...
未找到
EditorDiskAssetCatalog.cpp
浏览该文件的文档.
15Result<DiskAssetScanResult> scanError(EditorStatus status, const char* rule, std::string message) {
27DiskAssetCatalog::DiskAssetCatalog(std::filesystem::path projectRoot, MemoryAssetDatabase* database)
34std::filesystem::path DiskAssetCatalog::resolveContent(const std::filesystem::path& relative) const {
44Result<void> DiskAssetCatalog::writeSidecar(const std::filesystem::path& contentRelativePath, AssetGuid guid,
48 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.asset.sidecar-invalid"),
58 return eve::editing::failed<void>(EditorStatus::Failed, RuleId("editor.asset.sidecar-directory"), ec.message());
74 return eve::editing::failed<void>(EditorStatus::Failed, RuleId("editor.asset.sidecar-replace"), ec.message());
84 if (!std::filesystem::exists(contentRoot_)) return eve::editing::applied<DiskAssetScanResult>(std::move(result));
86 for (std::filesystem::recursive_directory_iterator iterator(contentRoot_, ec), end; iterator != end && !ec;
124 const bool changed = previous == fingerprints_.end() || !previous->second.starts_with(fingerprint) ||
207 return eve::editing::failed<AutosaveDraft>(EditorStatus::Rejected, RuleId(rule), std::move(message));
244 if (path.empty()) return failure(EditorStatus::Rejected, "editor.document.invalid-uri", "Rejected resource URI");
249 const std::string json{std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>()};
274 if (path.empty()) return failure(EditorStatus::Rejected, "editor.document.invalid-uri", "Rejected resource URI");
304 if (!output) return failure(EditorStatus::Failed, "editor.document.temp-open", "Cannot open temp file");
320Result<StoredDocument> DiskAtomicDocumentStore::failure(EditorStatus status, const char* rule, std::string message) {
327 return MoveFileExW(temporary.c_str(), destination.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) != 0;
343Result<StoredDocument> AutosaveService::writeDraft(const DocumentSnapshot& snapshot, const EditorValue& content) {
345 return eve::editing::failed<StoredDocument>(EditorStatus::Rejected, RuleId("editor.autosave.invalid"),
367 if (!store_ || document.empty()) return draftFailure("editor.autosave.invalid", "Autosave store is required");
373 return draftFailure("editor.autosave.unsupported-schema", "Autosave draft schemaVersion must be 1");
385bool AutosaveService::shouldOfferRecovery(const AutosaveDraft& draft, const DocumentSnapshot& formal) const {
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:339
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:286
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:365
bool empty() const noexcept
True when no compatibility spelling has been assigned.
Definition Identity.h:377
Deterministic owning value tree shared by authoring hosts.
Definition EditingValue.h:23
Result< AutosaveDraft > readDraft(const DocumentId &document) const
Read a draft and validate its schema.
Definition EditorDiskAssetCatalog.cpp:366
bool shouldOfferRecovery(const AutosaveDraft &draft, const DocumentSnapshot &formal) const
True when a newer draft differs from the current formal disk base.
Definition EditorDiskAssetCatalog.cpp:385
std::string draftUri(const DocumentId &document) const
Return the stable draft URI for one document.
Definition EditorDiskAssetCatalog.cpp:335
Result< StoredDocument > writeDraft(const DocumentSnapshot &snapshot, const EditorValue &content)
Write one revisioned draft under autosave://project/document.draft.
Definition EditorDiskAssetCatalog.cpp:343
Result< DiskAssetScanResult > scan()
Scan every sidecar and atomically publish valid records.
Definition EditorDiskAssetCatalog.cpp:78
Result< void > writeSidecar(const std::filesystem::path &contentRelativePath, AssetGuid guid, std::string typeId, std::uint32_t schemaVersion=1)
Create/replace a sidecar for a Content-relative source file.
Definition EditorDiskAssetCatalog.cpp:44
DiskAssetCatalog(std::filesystem::path projectRoot, MemoryAssetDatabase *database)
Create a host-driven disk asset catalog.
Definition EditorDiskAssetCatalog.cpp:27
Result< DiskAssetScanResult > poll()
Rescan and report only content/sidecar fingerprints that changed.
Definition EditorDiskAssetCatalog.cpp:151
Result< StoredDocument > compareAndSwap(const std::string &resourceUri, Revision expectedRevision, const std::string &expectedContentHash, const EditorValue &content) override
CAS and atomically replace one document envelope on disk.
Definition EditorDiskAssetCatalog.cpp:269
DiskAtomicDocumentStore(std::filesystem::path projectRoot)
Create a store rooted at a project directory.
Definition EditorDiskAssetCatalog.cpp:212
std::filesystem::path resolve(const std::string &resourceUri) const
Resolve a logical URI to a canonical project path, or an empty path when rejected.
Definition EditorDiskAssetCatalog.cpp:218
Result< StoredDocument > read(const std::string &resourceUri) const override
Read and validate the latest atomic document envelope.
Definition EditorDiskAssetCatalog.cpp:242
virtual Result< StoredDocument > read(const std::string &resourceUri) const =0
Read the latest value for a resource URI.
virtual Result< StoredDocument > compareAndSwap(const std::string &resourceUri, Revision expectedRevision, const std::string &expectedContentHash, const EditorValue &content)=0
Replace a value only when the expected disk revision still matches.
Thread-neutral in-memory asset index used by editor hosts and tests.
Definition EditorAssetDatabase.h:71
Result< AssetRecord > publish(AssetRecord record, std::vector< AssetDependency > dependencies={})
Atomically publish one validated record and its dependencies.
Definition EditorAssetDatabase.cpp:26
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
Diagnostic ruleDiagnostic(eve::DiagnosticCode code, RuleId rule, DiagnosticSeverity severity, std::string message)
Build an owning common diagnostic carrying an open editing rule identity.
Definition EditingResult.cpp:20
Definition ActionPreviewController.cpp:6
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
@ InvalidArgument
@ NotFound
@ Conflict
Value snapshot stored by the editor asset index.
Definition EditorAssetDatabase.h:18
Persisted draft metadata used to decide whether recovery should be offered.
Definition EditorDiskDocumentStore.h:49
Result of one disk asset sidecar scan/poll.
Definition EditorDiskAssetCatalog.h:13
Immutable document metadata snapshot.
Definition EditorDocumentService.h:53
std::string diskContentHash
Definition EditorDocumentService.h:60
DocumentRevision revision
Definition EditorDocumentService.h:59
Value snapshot returned by an atomic document store.
Definition EditorDocumentService.h:78