Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Oct 22, 2024
1 parent a35ecce commit 7511c42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
19 changes: 0 additions & 19 deletions packages/assetpack/src/core/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,5 @@ export class Asset

return res;
}

toCacheData(saveHash: boolean): CachedAsset
{
const data: CachedAsset = {
isFolder: this.isFolder,
parent: this.parent?.path,
transformParent: this.transformParent?.path,
metaData: { ...this.metaData },
inheritedMetaData: { ...this.inheritedMetaData },
transformData: { ...this.transformData }
};

if (!this.isFolder && saveHash)
{
data.hash = this.hash;
}

return data;
}
}

21 changes: 20 additions & 1 deletion packages/assetpack/src/core/AssetCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class AssetCache

private _serializeAsset(asset: Asset, schema: AssetCacheData['assets'], saveHash = false)
{
const serializeAsset: CachedAsset = asset.toCacheData(saveHash);
const serializeAsset: CachedAsset = this.toCacheData(asset, saveHash);

schema[asset.path] = serializeAsset;

Expand All @@ -66,6 +66,25 @@ export class AssetCache
this._serializeAsset(child, schema);
});
}

private toCacheData(asset: Asset, saveHash: boolean): CachedAsset
{
const data: CachedAsset = {
isFolder: asset.isFolder,
parent: asset.parent?.path,
transformParent: asset.transformParent?.path,
metaData: { ...asset.metaData },
inheritedMetaData: { ...asset.inheritedMetaData },
transformData: { ...asset.transformData }
};

if (!asset.isFolder && saveHash)
{
data.hash = asset.hash;
}

return data;
}
}

export interface CachedAsset
Expand Down

0 comments on commit 7511c42

Please sign in to comment.