Get rid of flawed Windows stat cache. b=456603 r=smichaud sr=dougt

This commit is contained in:
Josh Aas 2008-10-09 13:52:08 -04:00
Родитель 01851caf27
Коммит b6b1977117
2 изменённых файлов: 4 добавлений и 45 удалений

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

@ -719,8 +719,7 @@ NS_IMPL_ISUPPORTS2(nsDirEnumerator, nsISimpleEnumerator, nsIDirectoryEnumerator)
//-----------------------------------------------------------------------------
nsLocalFile::nsLocalFile()
: mDirty(PR_TRUE)
, mFollowSymlinks(PR_FALSE)
: mFollowSymlinks(PR_FALSE)
{
}
@ -760,8 +759,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
//-----------------------------------------------------------------------------
nsLocalFile::nsLocalFile(const nsLocalFile& other)
: mDirty(PR_TRUE)
, mFollowSymlinks(other.mFollowSymlinks)
: mFollowSymlinks(other.mFollowSymlinks)
, mWorkingPath(other.mWorkingPath)
{
}
@ -799,10 +797,6 @@ nsLocalFile::ResolveShortcut()
nsresult
nsLocalFile::ResolveAndStat()
{
// if we aren't dirty then we are already done
if (!mDirty)
return NS_OK;
// we can't resolve/stat anything that isn't a valid NSPR addressable path
if (mWorkingPath.IsEmpty())
return NS_ERROR_FILE_INVALID_PATH;
@ -825,7 +819,6 @@ nsLocalFile::ResolveAndStat()
|| mFileInfo64.type != PR_FILE_FILE
|| !IsShortcutPath(mWorkingPath))
{
mDirty = PR_FALSE;
return NS_OK;
}
@ -844,7 +837,6 @@ nsLocalFile::ResolveAndStat()
if (NS_FAILED(GetFileInfo(mResolvedPath, &mFileInfo64)))
return NS_ERROR_FILE_NOT_FOUND;
mDirty = PR_FALSE;
return NS_OK;
}
@ -881,8 +873,6 @@ nsLocalFile::InitWithFile(nsILocalFile *aFile)
NS_IMETHODIMP
nsLocalFile::InitWithPath(const nsAString &filePath)
{
MakeDirty();
nsAString::const_iterator begin, end;
filePath.BeginReading(begin);
filePath.EndReading(end);
@ -1101,8 +1091,6 @@ nsLocalFile::AppendInternal(const nsAFlatString &node, PRBool multipleComponents
else if (node.FindChar(L'\\') != kNotFound)
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
#endif
MakeDirty();
mWorkingPath.Append(NS_LITERAL_STRING("\\") + node);
@ -1266,7 +1254,6 @@ nsLocalFile::Normalize()
mWorkingPath.Truncate(filePathLen--);
}
MakeDirty();
#else // WINCE
// WINCE FIX
#endif
@ -1295,8 +1282,6 @@ nsLocalFile::GetLeafName(nsAString &aLeafName)
NS_IMETHODIMP
nsLocalFile::SetLeafName(const nsAString &aLeafName)
{
MakeDirty();
if(mWorkingPath.IsEmpty())
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
@ -1681,8 +1666,6 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, PRBool foll
// If we moved, we want to adjust this.
if (move)
{
MakeDirty();
nsAutoString newParentPath;
newParentDir->GetPath(newParentPath);
@ -1836,7 +1819,6 @@ nsLocalFile::Remove(PRBool recursive)
if (rv == (nsresult)-1)
rv = NSRESULT_FOR_ERRNO();
MakeDirty();
return rv;
}
@ -1905,8 +1887,6 @@ nsLocalFile::SetLastModifiedTime(PRInt64 aLastModifiedTime)
// results as SetLastModifiedTimeOfLink)
rv = SetModDate(aLastModifiedTime, mResolvedPath.get());
if (NS_SUCCEEDED(rv))
MakeDirty();
return rv;
}
@ -1917,12 +1897,7 @@ nsLocalFile::SetLastModifiedTimeOfLink(PRInt64 aLastModifiedTime)
{
// The caller is assumed to have already called IsSymlink
// and to have found that this file is a link.
nsresult rv = SetModDate(aLastModifiedTime, mWorkingPath.get());
if (NS_SUCCEEDED(rv))
MakeDirty();
return rv;
return SetModDate(aLastModifiedTime, mWorkingPath.get());
}
nsresult
@ -2118,19 +2093,14 @@ nsLocalFile::SetFileSize(PRInt64 aFileSize)
FILE_ATTRIBUTE_NORMAL, // file attributes
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
return ConvertWinError(GetLastError());
}
// seek the file pointer to the new, desired end of file
// and then truncate the file at that position
rv = NS_ERROR_FAILURE;
aFileSize = MyFileSeek64(hFile, aFileSize, FILE_BEGIN);
if (aFileSize != -1 && SetEndOfFile(hFile))
{
MakeDirty();
rv = NS_OK;
}
CloseHandle(hFile);
return rv;
@ -2214,7 +2184,6 @@ nsLocalFile::Exists(PRBool *_retval)
NS_ENSURE_ARG(_retval);
*_retval = PR_FALSE;
MakeDirty();
nsresult rv = ResolveAndStat();
*_retval = NS_SUCCEEDED(rv);
@ -2568,7 +2537,6 @@ nsLocalFile::GetFollowLinks(PRBool *aFollowLinks)
NS_IMETHODIMP
nsLocalFile::SetFollowLinks(PRBool aFollowLinks)
{
MakeDirty();
mFollowSymlinks = aFollowLinks;
return NS_OK;
}

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

@ -52,13 +52,6 @@
#include "nsIClassInfoImpl.h"
#include "windows.h"
// For older version (<6.0) of the VC Compiler
#if (_MSC_VER == 1100)
#include <objbase.h>
DEFINE_OLEGUID(IID_IPersistFile, 0x0000010BL, 0, 0);
#endif
#include "shlobj.h"
#include <sys/stat.h>
@ -96,7 +89,6 @@ private:
nsLocalFile(const nsLocalFile& other);
~nsLocalFile() {}
PRPackedBool mDirty; // cached information can only be used when this is PR_FALSE
PRPackedBool mFollowSymlinks; // should we follow symlinks when working on this file
// this string will always be in native format!
@ -110,10 +102,9 @@ private:
// mWorkingPath
nsString mShortWorkingPath;
// call ResolveAndStat() whenever this needs to be up-to-date
PRFileInfo64 mFileInfo64;
void MakeDirty() { mDirty = PR_TRUE; mShortWorkingPath.Truncate(); }
nsresult ResolveAndStat();
nsresult ResolveShortcut();