Bug 670911: Skip reset of NTFS ACLs when renaming file w/o changing directory. r=bsmedberg, sr=neil

This commit is contained in:
Jason Duell 2011-07-28 04:13:06 -07:00
Родитель 6869877585
Коммит bf52ae9069
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -1356,7 +1356,8 @@ nsLocalFile::GetVersionInfoField(const char* aField, nsAString& _retval)
nsresult
nsLocalFile::CopySingleFile(nsIFile *sourceFile, nsIFile *destParent,
const nsAString &newName,
PRBool followSymlinks, PRBool move)
PRBool followSymlinks, PRBool move,
PRBool skipNtfsAclReset)
{
nsresult rv;
nsAutoString filePath;
@ -1442,8 +1443,10 @@ nsLocalFile::CopySingleFile(nsIFile *sourceFile, nsIFile *destParent,
if (!copyOK) // CopyFileEx and MoveFileEx return zero at failure.
rv = ConvertWinError(GetLastError());
else if (move) // Set security permissions to inherit from parent.
else if (move && !skipNtfsAclReset)
{
// Set security permissions to inherit from parent.
// Note: propagates to all children: slow for big file trees
PACL pOldDACL = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
::GetNamedSecurityInfoW((LPWSTR)destPath.get(), SE_FILE_OBJECT,
@ -1476,7 +1479,6 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, PRBool foll
if (!newParentDir)
{
// no parent was specified. We must rename.
if (newName.IsEmpty())
return NS_ERROR_INVALID_ARG;
@ -1542,7 +1544,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, PRBool foll
if (move || !isDir || (isSymlink && !followSymlinks))
{
// Copy/Move single file, or move a directory
rv = CopySingleFile(this, newParentDir, newName, followSymlinks, move);
rv = CopySingleFile(this, newParentDir, newName, followSymlinks, move,
!aParentDir);
done = NS_SUCCEEDED(rv);
// If we are moving a directory and that fails, fallback on directory
// enumeration. See bug 231300 for details.

Просмотреть файл

@ -123,7 +123,8 @@ private:
PRBool followSymlinks, PRBool move);
nsresult CopySingleFile(nsIFile *source, nsIFile* dest,
const nsAString &newName,
PRBool followSymlinks, PRBool move);
PRBool followSymlinks, PRBool move,
PRBool skipNtfsAclReset = PR_FALSE);
nsresult SetModDate(PRInt64 aLastModifiedTime, const PRUnichar *filePath);
nsresult HasFileAttribute(DWORD fileAttrib, PRBool *_retval);