Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15425762
D19136.id45857.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D19136.id45857.diff
View Options
diff --git a/resources/sql/autopatches/20180223.log.01.bytelength.sql b/resources/sql/autopatches/20180223.log.01.bytelength.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180223.log.01.bytelength.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildlog
+ ADD byteLength BIGINT UNSIGNED NOT NULL;
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
@@ -12,6 +12,7 @@
protected $duration;
protected $live;
protected $filePHID;
+ protected $byteLength;
private $buildTarget = self::ATTACHABLE;
private $rope;
@@ -42,7 +43,8 @@
return id(new HarbormasterBuildLog())
->setBuildTargetPHID($build_target->getPHID())
->setDuration(null)
- ->setLive(1);
+ ->setLive(1)
+ ->setByteLength(0);
}
public function scheduleRebuild($force) {
@@ -70,6 +72,7 @@
'live' => 'bool',
'filePHID' => 'phid?',
+ 'byteLength' => 'uint64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_buildtarget' => array(
@@ -341,24 +344,28 @@
$append_data = $rope->getPrefixBytes($data_limit);
$data_size = strlen($append_data);
- if ($append_id) {
- queryfx(
- $conn_w,
- 'UPDATE %T SET chunk = CONCAT(chunk, %B), size = %d WHERE id = %d',
- $chunk_table,
- $append_data,
- $prefix_size + $data_size,
- $append_id);
- } else {
- $this->writeChunk($encoding_text, $data_size, $append_data);
- }
+ $this->openTransaction();
+ if ($append_id) {
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET chunk = CONCAT(chunk, %B), size = %d WHERE id = %d',
+ $chunk_table,
+ $append_data,
+ $prefix_size + $data_size,
+ $append_id);
+ } else {
+ $this->writeChunk($encoding_text, $data_size, $append_data);
+ }
+
+ $this->byteLength += $data_size;
+ $this->save();
+ $this->saveTransaction();
$rope->removeBytesFromHead($data_size);
}
}
-
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/harbormaster/worker/HarbormasterLogWorker.php b/src/applications/harbormaster/worker/HarbormasterLogWorker.php
--- a/src/applications/harbormaster/worker/HarbormasterLogWorker.php
+++ b/src/applications/harbormaster/worker/HarbormasterLogWorker.php
@@ -57,6 +57,19 @@
$data = $this->getTaskData();
$is_force = idx($data, 'force');
+ if (!$log->getByteLength() || $is_force) {
+ $iterator = $log->newChunkIterator()
+ ->setAsString(true);
+
+ $byte_length = 0;
+ foreach ($iterator as $block) {
+ $byte_length += strlen($block);
+ }
+ $log
+ ->setByteLength($byte_length)
+ ->save();
+ }
+
if ($log->canCompressLog()) {
$log->compressLog();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 5:56 AM (6 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719675
Default Alt Text
D19136.id45857.diff (3 KB)
Attached To
Mode
D19136: In Harbormaster, record byte length on the build logs
Attached
Detach File
Event Timeline
Log In to Comment