From f9985a2222aa94e367361e08ca80df6ada9e966a Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Wed, 19 Oct 2011 02:57:26 +0000 Subject: [PATCH] * add the feature of restart svn sync. --- Makefile | 2 ++ module/svn/model.php | 81 +++++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 81ec78d582..7cdaa0a69b 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,8 @@ tgz: # create my.min.js rm zentaopms/www/js/my.min.js java -jar ~/bin/yuicompressor/build/yuicompressor-2.4.6.jar www/js/my.full.js > zentaopms/www/js/my.in.js + # create the restart file for svn. + touch zentaopms/module/svn/restart # touch the front.class.php to make it's mtime to new. touch zentaopms/lib/front/front.class.php # delee the unused files. diff --git a/module/svn/model.php b/module/svn/model.php index 7b7fb4dec7..e203337396 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -37,6 +37,14 @@ class svnModel extends model */ public $logRoot = ''; + /** + * The restart file. + * + * @var string + * @access public + */ + public $restartFile = ''; + /** * The root path of a repo * @@ -53,30 +61,6 @@ class svnModel extends model */ public $users = array(); - /** - * Set the repos. - * - * @access public - * @return void - */ - public function setRepos() - { - if(!$this->config->svn->repos) die("You must set one svn repo.\n"); - $this->repos = $this->config->svn->repos; - } - - /** - * Set the log root. - * - * @access public - * @return void - */ - public function setLogRoot() - { - $this->logRoot = $this->app->getTmpRoot() . 'svn/'; - if(!is_dir($this->logRoot)) mkdir($this->logRoot); - } - /** * Run. * @@ -87,6 +71,7 @@ class svnModel extends model { $this->setRepos(); $this->setLogRoot(); + $this->setRestartFile(); $this->loadModel('action'); foreach($this->repos as $name => $repo) @@ -130,10 +115,57 @@ class svnModel extends model } $this->saveLastRevision($savedRevision); $this->printLog("save revision $savedRevision"); + $this->deleteRestartFile(); $this->printLog("\n\nrepo $name finished"); } } + /** + * Set the log root. + * + * @access public + * @return void + */ + public function setLogRoot() + { + $this->logRoot = $this->app->getTmpRoot() . 'svn/'; + if(!is_dir($this->logRoot)) mkdir($this->logRoot); + } + + /** + * Set the restart file. + * + * @access public + * @return void + */ + public function setRestartFile() + { + $this->restartFile = dirname(__FILE__) . '/restart'; + } + + /** + * Delete the restart file. + * + * @access public + * @return void + */ + public function deleteRestartFile() + { + if(is_file($this->restartFile)) unlink($this->restartFile); + } + + /** + * Set the repos. + * + * @access public + * @return void + */ + public function setRepos() + { + if(!$this->config->svn->repos) die("You must set one svn repo.\n"); + $this->repos = $this->config->svn->repos; + } + /** * Set repo. * @@ -524,6 +556,7 @@ class svnModel extends model public function getSavedRevision() { if(!file_exists($this->logFile)) return 0; + if(file_exists($this->restartFile)) return 0; return (int)trim(file_get_contents($this->logFile)); }