Commit bf6f05a1006f920c513133bc3bde354b494ae6bc
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
Showing
1 changed file
with
36 additions
and
17 deletions
plugins/ktcore/admin/manageCleanup.php
| ... | ... | @@ -6,31 +6,31 @@ |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2008, 2009 KnowledgeTree Inc. |
| 8 | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | 12 | * Free Software Foundation. |
| 13 | - * | |
| 13 | + * | |
| 14 | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | 17 | * details. |
| 18 | - * | |
| 18 | + * | |
| 19 | 19 | * You should have received a copy of the GNU General Public License |
| 20 | 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 | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | 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 | 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 | 34 | * copyright notice. |
| 35 | 35 | * Contributor( s): ______________________________________ |
| 36 | 36 | * |
| ... | ... | @@ -53,10 +53,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { |
| 53 | 53 | $this->aIgnore = array( |
| 54 | 54 | '.', '..', |
| 55 | 55 | 'CVS', |
| 56 | + '.DS_Store', | |
| 56 | 57 | '.empty', |
| 57 | 58 | '.htaccess', |
| 58 | 59 | '.cvsignore', |
| 59 | 60 | '.svn', |
| 61 | + '.git' | |
| 60 | 62 | ); |
| 61 | 63 | |
| 62 | 64 | $oConfig =& KTConfig::getSingleton(); |
| ... | ... | @@ -67,19 +69,19 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { |
| 67 | 69 | |
| 68 | 70 | function do_main() |
| 69 | 71 | { |
| 70 | - | |
| 72 | + | |
| 71 | 73 | $oForm = new KTForm; |
| 72 | 74 | $oForm->setOptions(array( |
| 73 | 75 | 'label' => _kt('Document Storage Verification'), |
| 74 | 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 | 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 | 85 | function do_verify() { |
| 84 | 86 | global $aFoldersToRemove; |
| 85 | 87 | global $aFilesToRemove; |
| ... | ... | @@ -115,7 +117,7 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { |
| 115 | 117 | print "Could not open directory: $fullpath\n"; |
| 116 | 118 | } |
| 117 | 119 | while (($filename = readdir($dh)) !== false) { |
| 118 | - if (in_array($filename, $this->aIgnore)) { continue; } | |
| 120 | + if (in_array($filename, $this->aIgnore)) { continue; } | |
| 119 | 121 | $subrelpath = sprintf("%s/%s", $path, $filename); |
| 120 | 122 | if (substr($subrelpath, 0, 1) == "/") { |
| 121 | 123 | $subrelpath = substr($subrelpath, 1); |
| ... | ... | @@ -125,7 +127,12 @@ class ManageCleanupDispatcher extends KTAdminDispatcher { |
| 125 | 127 | $this->checkDirectory($subrelpath); |
| 126 | 128 | } |
| 127 | 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 | 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 | 162 | function checkRepoDocument($oDocument) { |
| 144 | 163 | global $aRepoDocumentProblems; |
| 145 | 164 | $aDCVs = KTDocumentContentVersion::getByDocument($oDocument); | ... | ... |