summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch/Client.cpp
diff options
context:
space:
mode:
authorZeroC Staff <git@zeroc.com>2004-01-22 18:58:42 +0000
committerZeroC Staff <git@zeroc.com>2004-01-22 18:58:42 +0000
commitbe30a3b5321248ca3cf2946866f2c99a8afdeded (patch)
tree1ae3d33befc3a74f146ba8d4d066eecb8fada052 /cpp/src/IcePatch/Client.cpp
parentminor fixes (diff)
downloadice-be30a3b5321248ca3cf2946866f2c99a8afdeded.tar.bz2
ice-be30a3b5321248ca3cf2946866f2c99a8afdeded.tar.xz
ice-be30a3b5321248ca3cf2946866f2c99a8afdeded.zip
Added extra file integrity checks to icepatchclient.
Diffstat (limited to 'cpp/src/IcePatch/Client.cpp')
-rw-r--r--cpp/src/IcePatch/Client.cpp84
1 files changed, 74 insertions, 10 deletions
diff --git a/cpp/src/IcePatch/Client.cpp b/cpp/src/IcePatch/Client.cpp
index 7bcd89fb893..1b047ac9651 100644
--- a/cpp/src/IcePatch/Client.cpp
+++ b/cpp/src/IcePatch/Client.cpp
@@ -528,21 +528,21 @@ IcePatch::Client::patch(const DirectoryDescPtr& dirDesc, const string& indent) c
MyProgressCB progressCB;
+ bool update = false;
+
FileInfo info = getFileInfo(path, false);
switch(info.type)
{
case FileTypeNotExist:
{
- orphaned.erase(path + ".bz2");
- getRegular(regDesc->reg, progressCB);
+ update = true;
break;
}
case FileTypeDirectory:
{
removeRecursive(path);
- orphaned.erase(path + ".bz2");
- getRegular(regDesc->reg, progressCB);
+ update = true;
break;
}
@@ -550,18 +550,24 @@ IcePatch::Client::patch(const DirectoryDescPtr& dirDesc, const string& indent) c
{
ByteSeq md5;
- string pathMD5 = path + ".md5";
- FileInfo infoMD5 = getFileInfo(pathMD5, false);
- if(infoMD5.type == FileTypeRegular && infoMD5.time >= info.time)
+ if(_thorough)
{
- md5 = getMD5(path);
+ md5 = calcMD5(path);
+ }
+ else
+ {
+ string pathMD5 = path + ".md5";
+ FileInfo infoMD5 = getFileInfo(pathMD5, false);
+ if(infoMD5.type == FileTypeRegular && infoMD5.time >= info.time)
+ {
+ md5 = getMD5(path);
+ }
}
if(md5 != regDesc->md5)
{
removeRecursive(path);
- orphaned.erase(path + ".bz2");
- getRegular(regDesc->reg, progressCB);
+ update = true;
}
else
{
@@ -571,6 +577,64 @@ IcePatch::Client::patch(const DirectoryDescPtr& dirDesc, const string& indent) c
break;
}
}
+
+ if(update)
+ {
+ orphaned.erase(path + ".bz2");
+
+ int retries = 0;
+ while(true)
+ {
+ //
+ // Retrieve file from server.
+ //
+ getRegular(regDesc->reg, progressCB);
+
+ //
+ // Get the latest file description from server, as
+ // the file may mave recently changed.
+ //
+ regDesc = RegularDescPtr::dynamicCast(regDesc->reg->describe());
+ if(!regDesc)
+ {
+ removeRecursive(path);
+
+ FileAccessException ex;
+ ex.reason = "Unexpected error accessing `" + path + "' remotely.";
+ throw ex;
+ }
+
+ //
+ // Compare the icepatch and locally built MD5s. If
+ // they differ, try again unless we've hit the
+ // retry limit.
+ //
+ ByteSeq md5;
+ string pathMD5 = path + ".md5";
+ FileInfo infoMD5 = getFileInfo(pathMD5, false);
+ if(infoMD5.type == FileTypeRegular)
+ {
+ md5 = getMD5(path);
+ }
+
+ if(regDesc->md5 == md5)
+ {
+ break;
+ }
+ else if(retries < 3)
+ {
+ ++retries;
+ }
+ else
+ {
+ removeRecursive(path);
+
+ FileAccessException ex;
+ ex.reason = "Error patching `" + path + "'.";
+ throw ex;
+ }
+ }
+ }
}
}