Commit:    cb41be0fb0a690e01d1f743779bf49e0d1ea38c2
Author:    Anatol Belski <[email protected]>         Tue, 19 Sep 2017 18:43:35 +0200
Parents:   fd4448d3d3edae90a186c859bebfccbd197d555e
Branches:  master

Link:       
http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=cb41be0fb0a690e01d1f743779bf49e0d1ea38c2

Log:
Truncate the db file for reset

Changed paths:
  M  include/Branch.php


Diff:
diff --git a/include/Branch.php b/include/Branch.php
index 6cf84aa..4bb86a5 100644
--- a/include/Branch.php
+++ b/include/Branch.php
@@ -44,10 +44,14 @@ class Branch {
        /* If both read and write are requested, read and yield data first. The 
fd
                is still open and the exclusive lock is held. Call the function 
once
                more to write. */
-       protected function atomicDataRW($read = true, $write = false)
+       protected function atomicDataRW($read = true, $write = false, $truncate 
= false)
        {
                if ($write) {
-                       $open_mode = "cb+";
+                       if ($truncate) {
+                               $open_mode = "wb+";
+                       } else {
+                               $open_mode = "cb+";
+                       }
                        $lock_mode = LOCK_EX;
                } else {
                        $open_mode = "rb";
@@ -64,6 +68,7 @@ class Branch {
                }
 
                if ($read) {
+                       rewind($this->db_fd);
                        $j = "";
                        while(!feof($this->db_fd)) {
                                $j .= fread($this->db_fd, 1024);
@@ -354,10 +359,10 @@ class Branch {
        function resetBuildInfo()
        {
                if ($this->requiredBuildRunsReached()) {
-                       $this->data = $this->readdata();
+                       $this->data = $this->readData();
                        $this->data->build_num = 0;
                        $this->data->builds = array();
-                       $this->writeData();
+                       $this->atomicDataRW(false, true, true);
                }
        }


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to