Page MenuHomePhabricator

D19152.diff
No OneTemporary

D19152.diff

diff --git a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
--- a/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
+++ b/src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
@@ -18,6 +18,13 @@
'param' => 'id',
'help' => pht('Build Target ID to attach the log to.'),
),
+ array(
+ 'name' => 'rate',
+ 'param' => 'bytes',
+ 'help' => pht(
+ 'Limit the rate at which the log is written, to test '.
+ 'live log streaming.'),
+ ),
));
}
@@ -54,7 +61,37 @@
pht('Reading log content from stdin...'));
$content = file_get_contents('php://stdin');
- $log->append($content);
+
+ $rate = $args->getArg('rate');
+ if ($rate) {
+ if ($rate <= 0) {
+ throw new Exception(
+ pht(
+ 'Write rate must be more than 0 bytes/sec.'));
+ }
+
+ echo tsprintf(
+ "%s\n",
+ pht('Writing log, slowly...'));
+
+ $offset = 0;
+ $total = strlen($content);
+ $pieces = str_split($content, $rate);
+
+ $bar = id(new PhutilConsoleProgressBar())
+ ->setTotal($total);
+
+ foreach ($pieces as $piece) {
+ $log->append($piece);
+ $bar->update(strlen($piece));
+ sleep(1);
+ }
+
+ $bar->done();
+
+ } else {
+ $log->append($content);
+ }
echo tsprintf(
"%s\n",
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
@@ -492,7 +492,7 @@
'UPDATE %T SET
chunk = CONCAT(chunk, %B),
size = %d,
- tailOffset = headOffset + %d,
+ tailOffset = headOffset + %d
WHERE
id = %d',
$chunk_table,

File Metadata

Mime Type
text/plain
Expires
Thu, May 16, 1:16 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6289551
Default Alt Text
D19152.diff (2 KB)

Event Timeline