Commit bf6f05a1006f920c513133bc3bde354b494ae6bc

Authored by Megan Watson
1 parent 2b4eaf9c

KTC-711 Added a check on the backup documents (docId.bak)

"Document Storage Verification inconsistent with the contents of the repository after upload of the language test documents.."

Committed by: Megan Watson
plugins/ktcore/admin/manageCleanup.php
@@ -6,31 +6,31 @@ @@ -6,31 +6,31 @@
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 * Portions copyright The Jam Warehouse Software (Pty) Limited 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9 - * 9 + *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
12 * Free Software Foundation. 12 * Free Software Foundation.
13 - * 13 + *
14 * This program is distributed in the hope that it will be useful, but WITHOUT 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details. 17 * details.
18 - * 18 + *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 - *  
22 - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, 21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 * California 94120-7775, or email info@knowledgetree.com. 23 * California 94120-7775, or email info@knowledgetree.com.
24 - * 24 + *
25 * The interactive user interfaces in modified source and object code versions 25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under 26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU General Public License version 3. 27 * Section 5 of the GNU General Public License version 3.
28 - * 28 + *
29 * In accordance with Section 7(b) of the GNU General Public License version 3, 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33 - * must display the words "Powered by KnowledgeTree" and retain the original 33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 * copyright notice. 34 * copyright notice.
35 * Contributor( s): ______________________________________ 35 * Contributor( s): ______________________________________
36 * 36 *
@@ -53,10 +53,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { @@ -53,10 +53,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher {
53 $this->aIgnore = array( 53 $this->aIgnore = array(
54 '.', '..', 54 '.', '..',
55 'CVS', 55 'CVS',
  56 + '.DS_Store',
56 '.empty', 57 '.empty',
57 '.htaccess', 58 '.htaccess',
58 '.cvsignore', 59 '.cvsignore',
59 '.svn', 60 '.svn',
  61 + '.git'
60 ); 62 );
61 63
62 $oConfig =& KTConfig::getSingleton(); 64 $oConfig =& KTConfig::getSingleton();
@@ -67,19 +69,19 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { @@ -67,19 +69,19 @@ class ManageCleanupDispatcher extends KTAdminDispatcher {
67 69
68 function do_main() 70 function do_main()
69 { 71 {
70 - 72 +
71 $oForm = new KTForm; 73 $oForm = new KTForm;
72 $oForm->setOptions(array( 74 $oForm->setOptions(array(
73 'label' => _kt('Document Storage Verification'), 75 'label' => _kt('Document Storage Verification'),
74 'description' => _kt('This process performs a check to see if the documents in your repositories all are stored on the back-end storage (usually on disk). This process can take many minutes or hours depending on the size of your repository.'), 76 'description' => _kt('This process performs a check to see if the documents in your repositories all are stored on the back-end storage (usually on disk). This process can take many minutes or hours depending on the size of your repository.'),
75 'submit_label' => _kt('verify document storage'), 77 'submit_label' => _kt('verify document storage'),
76 - 'action' => 'verify', 78 + 'action' => 'verify',
77 )); 79 ));
78 -  
79 - return $oForm->render(); 80 +
  81 + return $oForm->render();
80 } 82 }
81 -  
82 - 83 +
  84 +
83 function do_verify() { 85 function do_verify() {
84 global $aFoldersToRemove; 86 global $aFoldersToRemove;
85 global $aFilesToRemove; 87 global $aFilesToRemove;
@@ -115,7 +117,7 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { @@ -115,7 +117,7 @@ class ManageCleanupDispatcher extends KTAdminDispatcher {
115 print "Could not open directory: $fullpath\n"; 117 print "Could not open directory: $fullpath\n";
116 } 118 }
117 while (($filename = readdir($dh)) !== false) { 119 while (($filename = readdir($dh)) !== false) {
118 - if (in_array($filename, $this->aIgnore)) { continue; } 120 + if (in_array($filename, $this->aIgnore)) { continue; }
119 $subrelpath = sprintf("%s/%s", $path, $filename); 121 $subrelpath = sprintf("%s/%s", $path, $filename);
120 if (substr($subrelpath, 0, 1) == "/") { 122 if (substr($subrelpath, 0, 1) == "/") {
121 $subrelpath = substr($subrelpath, 1); 123 $subrelpath = substr($subrelpath, 1);
@@ -125,7 +127,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { @@ -125,7 +127,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher {
125 $this->checkDirectory($subrelpath); 127 $this->checkDirectory($subrelpath);
126 } 128 }
127 if (is_file($subfullpath)) { 129 if (is_file($subfullpath)) {
128 - $this->checkFile($subrelpath); 130 + // Check for backup file
  131 + if(substr($subrelpath, -4) == '.bak'){
  132 + $this->checkBackUpFile($subrelpath, $filename);
  133 + }else{
  134 + $this->checkFile($subrelpath);
  135 + }
129 } 136 }
130 } 137 }
131 } 138 }
@@ -140,6 +147,18 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { @@ -140,6 +147,18 @@ class ManageCleanupDispatcher extends KTAdminDispatcher {
140 } 147 }
141 } 148 }
142 149
  150 + function checkBackUpFile($path, $filename) {
  151 + $pos = strpos($filename, '.bak');
  152 + $doc = substr($filename, 0, $pos);
  153 +
  154 + $oDocument = Document::get($doc);
  155 +
  156 + if($oDocument instanceof Document || $oDocument instanceof DocumentProxy){
  157 + return;
  158 + }
  159 + $this->aFilesToRemove[] = $path;
  160 + }
  161 +
143 function checkRepoDocument($oDocument) { 162 function checkRepoDocument($oDocument) {
144 global $aRepoDocumentProblems; 163 global $aRepoDocumentProblems;
145 $aDCVs = KTDocumentContentVersion::getByDocument($oDocument); 164 $aDCVs = KTDocumentContentVersion::getByDocument($oDocument);