From 0f2779b74e5a8cfd5ad827de78194139975d616e Mon Sep 17 00:00:00 2001 From: "ssu%netscape.com" Date: Sat, 15 Jan 2000 06:01:39 +0000 Subject: [PATCH] fixing bug #21085. xpinstall now quits gracefully when destination file already exists in a file move and file copy operation. r=cathleen --- xpinstall/src/nsInstallFileOpItem.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/xpinstall/src/nsInstallFileOpItem.cpp b/xpinstall/src/nsInstallFileOpItem.cpp index ca21f09eeab..581be051b61 100644 --- a/xpinstall/src/nsInstallFileOpItem.cpp +++ b/xpinstall/src/nsInstallFileOpItem.cpp @@ -640,6 +640,16 @@ nsInstallFileOpItem::NativeFileOpFileCopyPrepare() return nsInstall::DOES_NOT_EXIST; else if(mTarget->IsFile()) return nsInstall::IS_FILE; + else + { + nsFileSpec tempVar; + + tempVar = *mTarget; + tempVar += mSrc->GetLeafName(); + + if(tempVar.Exists()) + return nsInstall::ALREADY_EXISTS; + } return nsInstall::SUCCESS; } @@ -749,8 +759,20 @@ nsInstallFileOpItem::NativeFileOpFileMovePrepare() { if(!mTarget->Exists()) return nsInstall::DOES_NOT_EXIST; + else if(mTarget->IsFile()) + return nsInstall::IS_FILE; else - return NativeFileOpFileCopyPrepare(); + { + nsFileSpec tempVar; + + tempVar = *mTarget; + tempVar += mSrc->GetLeafName(); + + if(tempVar.Exists()) + return nsInstall::ALREADY_EXISTS; + else + return NativeFileOpFileCopyPrepare(); + } } return nsInstall::SOURCE_DOES_NOT_EXIST;