Repository navigation
feat(collectives-publish) build targz - #2839
Conversation
Diskussion: |
Nothing in CollectiveService or the listeners touches collectives_st_sites. Before this commit that was an orphaned DB row; now it’s also a permanent static_sites/.tar.gz in appdata, plus a permanently occupied slug. Worth a follow-up issue at minimum. Comment: So this PR does not get to big I am going to create an extra issue for this topic: |
PharData::compress() on an archive with zero entries succeeds but writes no site.tar.gz (verified). buildArchive() returns the path anyway, writeToAppData()’s fopen fails, and the user gets ServiceException('Failed to open static site archive') → bare 500. Hard to reach in practice (every collective has a landing page), but a guard — if ($files === []) → UnprocessableEntityException, or a file_exists check on the compressed path — is cheaper than the mystery. Untested either way. Comment: |
Readability
Comment: unnecessary work - changing now and changing it back tomorrow.
Comment: OK
Comment: OK
Comment: OK - add info to log entry and catch exception for readable toast message. But no second logging of the same information.
Comment: OK - slicing the rule
Comment: Add to new documentation isssue: https://github.com/orgs/nextcloud-publish/projects/1/views/1?filterQuery=collectives&pane=issue&itemId=264855052&issue=nextcloud-publish%7Cgeneral%7C73 |
| foreach ($files as $path => $file) { | ||
| $localPath = $filesFolder . '/' . $index++; | ||
| $this->copyToLocal($file, $localPath); | ||
| $tar->addFile($localPath, (string)$path); |
There was a problem hiding this comment.
According to Claude, this is a severe problem:
PharData doesn’t append — every addFile() re-serializes the whole tar to disk.
So N files means N full rewrites: the work grows with N², and doubling the page count quadruples the publish time.
Measured locally (100 KB per file): 200 files → 1.4 s, 400 → 5.7 s, 800 → 24 s. A real wiki can blow the request timeout here and leave a pending row behind.
buildFromIterator() writes the archive once and takes exactly the mapping we already have (archivePath => localPath): same 800 files drop to 0.1 s. Would mean collecting the copies into an array in the loop and then:
$tar->buildFromIterator(new ArrayIterator($localPaths));
9ca1098 to
37ee4ef
Compare
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net>
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
34b44c6 to
731b7a0
Compare
Signed-off-by: Melpo <melpomene@posteo.net> Assisted-by: ClaudeCode:claude-sonnet-5
7d82ad6
into
feature/collectives-publish
📝 Summary
Goal
Provide a tar.gz archive for the Publish Service to retrieve.
Description
After selecting the data to be published, it needs to be prepared for the Publish Service.
After storing the archive in appData the external Publish Service gets
This involves several steps:
Acceptance Criteria
.templatesfolder or any of its subfolders.Limitation
A large Collective with many images may hit
max_execution_timeor proxy/browser timeouts when the archive is built synchronously.Dev Notes:
Test in console (nextcloud-docker-dev):
🖼️ Screenshots
Successful storage of tar.gz:

Failed - on second create with same slug (not yet published, so no update possible):

🚧 TODO
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)🤖 AI (if applicable)