Upload-Endpunkt POST /api/git/brews/:editId/assets (Magic Bytes, konfigurierbare Limits HB_ASSET_*, Dedupe, Commit ins Repo, Snapshot in brew_assets) und Auslieferung /git-assets/:shareId/:sha256.:ext gemäß ADR 0004. Postgres-Migration 0003, Mongo-Repo, Editor-Button, Drag-and-drop und Einfügen. Closes #10 Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
This commit was merged in pull request #26.
This commit is contained in:
1 parent
bbf838c5d6
commit
aeca3926a3
34 files changed
+1353
-11
No files matched your search
@@ -134,6 +134,8 @@ export const createGitService = ({ cfg, getStorage, api, splitTextStyleAndMetada
|
||||
locks,
|
||||
canEdit,
|
||||
isBrewOwner,
|
||||
loadEditableBrew,
|
||||
authorOf,
|
||||
|
||||
async listConnections(account) {
|
||||
const uid = requireUid(account);
|
||||
@@ -214,8 +216,8 @@ export const createGitService = ({ cfg, getStorage, api, splitTextStyleAndMetada
|
||||
* `expectedBlob`: Blob-ID, die wir zuletzt gesehen haben (null: Datei soll neu sein).
|
||||
* `overwrite`: Blob-ID aus gitOverwrite (bewusstes Überschreiben des fremden Stands).
|
||||
*/
|
||||
async commitContent(conn, { branch, filePath, content, expectedBlob, overwrite, author, signal }) {
|
||||
if(Buffer.byteLength(content) > cfg.maxFileBytes) throw new GitError('G09');
|
||||
async commitContent(conn, { branch, filePath, content, expectedBlob, overwrite, author, signal, message: customMessage, maxBytes = cfg.maxFileBytes, ignoreConflict = false }) {
|
||||
if(Buffer.byteLength(content) > maxBytes) throw new GitError('G09');
|
||||
for (let attempt = 1; attempt <= MAX_PUSH_ATTEMPTS; attempt++) {
|
||||
const result = await withConn(conn, async (repo)=>{
|
||||
const head = await client.fetchHead(repo, branch);
|
||||
@@ -226,11 +228,11 @@ export const createGitService = ({ cfg, getStorage, api, splitTextStyleAndMetada
|
||||
if(!parent) throw new GitError('G03', 'Der Standard-Branch der Verbindung existiert im Repository nicht.');
|
||||
}
|
||||
const remoteBlob = parent ? await client.blobAt(repo, parent, filePath) : null;
|
||||
if((remoteBlob ?? null) !== (expectedBlob ?? null) && overwrite !== (remoteBlob ?? 'none')) {
|
||||
if(!ignoreConflict && (remoteBlob ?? null) !== (expectedBlob ?? null) && overwrite !== (remoteBlob ?? 'none')) {
|
||||
if(expectedBlob === null && remoteBlob) throw new GitError('G06', undefined, { extra: { remoteCommitSha: parent, remoteBlobSha: remoteBlob } });
|
||||
throw new GitError('G01', undefined, { extra: { remoteCommitSha: parent, remoteBlobSha: remoteBlob } });
|
||||
}
|
||||
const message = `${remoteBlob ? 'Update' : 'Create'} ${filePath} via Homebrewery`;
|
||||
const message = customMessage ?? `${remoteBlob ? 'Update' : 'Create'} ${filePath} via Homebrewery`;
|
||||
const { commit, blob } = await client.buildCommit(repo, { parent, filePath, content, author, message, committer });
|
||||
if(head && blob === remoteBlob) return { commit: head, blob, unchanged: true };
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user