summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-06-16 22:17:17 +0000
committerMark Spruiell <mes@zeroc.com>2004-06-16 22:17:17 +0000
commit9b4bcdcd4ebede2272f19068a140913f6089b346 (patch)
treebc99741aee4d89ff4c13b74fa4e8d230cdf9a13e /cpp/src
parentadding checkDirectory (diff)
downloadice-9b4bcdcd4ebede2272f19068a140913f6089b346.tar.bz2
ice-9b4bcdcd4ebede2272f19068a140913f6089b346.tar.xz
ice-9b4bcdcd4ebede2272f19068a140913f6089b346.zip
changing calcMD5 to handle missing MD5s
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IcePatch/Util.cpp94
1 files changed, 26 insertions, 68 deletions
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp
index f586343de78..00686aa7356 100644
--- a/cpp/src/IcePatch/Util.cpp
+++ b/cpp/src/IcePatch/Util.cpp
@@ -551,99 +551,57 @@ IcePatch::calcMD5(const string& path, bool dynamic, const LoggerPtr& logger)
if(info.type == FileTypeDirectory)
{
StringSeq paths = readDirectory(path);
- if(dynamic)
+ for(StringSeq::const_iterator p = paths.begin(); p < paths.end(); ++p)
{
- //
- // Dynamically compute the MD5s for all files, but reuse the MD5s
- // already computed for subdirectories.
- //
- for(StringSeq::const_iterator p = paths.begin(); p < paths.end(); ++p)
+ if(!ignoreSuffix(*p))
{
- if(!ignoreSuffix(*p))
+ ByteSeq subBytesMD5;
+ FileInfo subInfo = getFileInfo(*p, true, logger);
+ if(subInfo.type == FileTypeDirectory)
{
- ByteSeq subBytesMD5;
- FileInfo subInfo = getFileInfo(*p, true, logger);
- if(subInfo.type == FileTypeDirectory)
+ try
{
subBytesMD5 = getMD5(*p);
}
- else if(subInfo.type == FileTypeRegular)
+ catch(const FileAccessException&)
{
subBytesMD5 = calcMD5(*p, dynamic, logger);
}
-
- //
- // We must take the filename into account, so that
- // renaming a file will change the summary MD5.
- //
- string plainFile = p->substr(p->rfind('/') + 1);
- copy(plainFile.begin(), plainFile.end(), back_inserter(bytes));
- copy(subBytesMD5.begin(), subBytesMD5.end(), back_inserter(bytes));
}
-
-#if 0
- string plainPath;
- ByteSeq subBytesMD5;
- if(getSuffix(*p) == "md5")
+ else if(subInfo.type == FileTypeRegular)
{
- plainPath = removeSuffix(*p);
- FileInfo plainPathInfo = getFileInfo(plainPath, true, logger);
- if(plainPathInfo.type != FileTypeDirectory)
+ //
+ // If dynamic is true or the MD5 file is out of date, then
+ // calculate a new MD5 for the file, otherwise use the
+ // existing MD5.
+ //
+ if(dynamic)
{
- continue; // Ignore MD5 for a regular file.
+ subBytesMD5 = calcMD5(*p, dynamic, logger);
}
-
- subBytesMD5 = getMD5(plainPath);
- }
- else if(!ignoreSuffix(*p))
- {
- plainPath = *p;
- FileInfo plainPathInfo = getFileInfo(*p, true, logger);
- if(plainPathInfo.type != FileTypeRegular)
+ else
{
- continue;
+ FileInfo subInfoMD5 = getFileInfo(*p + ".md5", false, logger);
+ if(subInfoMD5.type != FileTypeRegular || subInfoMD5.time < subInfo.time)
+ {
+ subBytesMD5 = calcMD5(*p, dynamic, logger);
+ }
+ else
+ {
+ subBytesMD5 = getMD5(*p);
+ }
}
-
- subBytesMD5 = calcMD5(plainPath, dynamic, logger);
- }
- else
- {
- continue;
}
//
// We must take the filename into account, so that
// renaming a file will change the summary MD5.
//
- string plainFile = plainPath.substr(plainPath.rfind('/') + 1);
+ string plainFile = p->substr(p->rfind('/') + 1);
copy(plainFile.begin(), plainFile.end(), back_inserter(bytes));
copy(subBytesMD5.begin(), subBytesMD5.end(), back_inserter(bytes));
-#endif
}
}
- else
- {
- //
- // Create a summary of all MD5 files.
- //
- for(StringSeq::const_iterator p = paths.begin(); p < paths.end(); ++p)
- {
- if(getSuffix(*p) == "md5")
- {
- string plainPath = removeSuffix(*p);
-
- //
- // We must take the filename into account, so that
- // renaming a file will change the summary MD5.
- //
- string plainFile = plainPath.substr(plainPath.rfind('/') + 1);
- copy(plainFile.begin(), plainFile.end(), back_inserter(bytes));
-
- ByteSeq subBytesMD5 = getMD5(plainPath);
- copy(subBytesMD5.begin(), subBytesMD5.end(), back_inserter(bytes));
- }
- }
- }
}
else
{