mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Update the file size in the file state cache.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29745 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -226,12 +226,13 @@ public class BufferedContentDiskDriver implements ExtendedDiskInterface,
|
||||
if(tctx.hasStateCache())
|
||||
{
|
||||
FileStateCache cache = tctx.getStateCache();
|
||||
FileState fstate = tctx.getStateCache().findFileState(path, false);
|
||||
FileState fstate = cache.findFileState(path, false);
|
||||
if(fstate != null)
|
||||
{
|
||||
FileInfo finfo = new FileInfo();
|
||||
finfo.copyFrom(info);
|
||||
|
||||
// TODO what if file state cache is stale or wrong? We are over-writing the "real" value.
|
||||
if(fstate.hasFileSize())
|
||||
{
|
||||
finfo.setFileSize(fstate.getFileSize());
|
||||
@@ -253,10 +254,24 @@ public class BufferedContentDiskDriver implements ExtendedDiskInterface,
|
||||
finfo.setAllocationSize( fstate.getAllocationSize());
|
||||
}
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("getFileInformation path" + path + ", returning:" + finfo +
|
||||
", readOnly:"+info.isReadOnly() +
|
||||
", fileId:"+info.getFileId() +
|
||||
", directoryId:" + info.getDirectoryId() +
|
||||
", mode" + info.getMode());
|
||||
}
|
||||
|
||||
return finfo;
|
||||
}
|
||||
}
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("getFileInformation returning:" + path + " returning" + info);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
}
|
||||
|
@@ -198,6 +198,7 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
|
||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||
x.setFileState(fstate);
|
||||
fstate.setProcessId(params.getProcessId());
|
||||
fstate.setSharedAccess( params.getSharedAccess());
|
||||
fstate.setFileStatus(FileStatus.FileExists);
|
||||
}
|
||||
}
|
||||
@@ -212,6 +213,8 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
|
||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||
x.setFileState(fstate);
|
||||
fstate.setFileStatus(FileStatus.FileExists);
|
||||
fstate.setProcessId(params.getProcessId());
|
||||
fstate.setSharedAccess( params.getSharedAccess());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +227,8 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
|
||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||
x.setFileState(fstate);
|
||||
fstate.setFileStatus(FileStatus.DirectoryExists);
|
||||
fstate.setProcessId(params.getProcessId());
|
||||
fstate.setSharedAccess( params.getSharedAccess());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,39 +67,46 @@ public class TempNetworkFile extends JavaNetworkFile implements NetworkFileState
|
||||
@Override
|
||||
public void writeFile(byte[] buf, int len, int pos) throws IOException
|
||||
{
|
||||
|
||||
super.writeFile(buf, len, pos);
|
||||
|
||||
long size = m_io.length();
|
||||
|
||||
setFileSize(size);
|
||||
if(fileState != null)
|
||||
{
|
||||
fileState.updateModifyDateTime();
|
||||
fileState.setFileSize(size);
|
||||
}
|
||||
super.writeFile(buf, len, pos);
|
||||
|
||||
setFileSize(m_io.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFile(byte[] buffer, int length, int position, long fileOffset)
|
||||
throws IOException
|
||||
{
|
||||
if(fileState != null)
|
||||
{
|
||||
fileState.updateModifyDateTime();
|
||||
}
|
||||
|
||||
super.writeFile(buffer, length, position, fileOffset);
|
||||
|
||||
setFileSize(m_io.length());
|
||||
long size = m_io.length();
|
||||
setFileSize(size);
|
||||
if(fileState != null)
|
||||
{
|
||||
fileState.updateModifyDateTime();
|
||||
fileState.setFileSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void truncateFile(long size) throws IOException
|
||||
{
|
||||
if(fileState != null)
|
||||
{
|
||||
fileState.updateModifyDateTime();
|
||||
}
|
||||
super.truncateFile(size);
|
||||
|
||||
setFileSize(size);
|
||||
if(fileState != null)
|
||||
{
|
||||
fileState.updateModifyDateTime();
|
||||
fileState.setFileSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
// For JLAN file state lock manager
|
||||
|
@@ -150,22 +150,29 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
||||
{
|
||||
CreateFileOperation c = (CreateFileOperation)operation;
|
||||
name = c.getName();
|
||||
|
||||
if(name != null)
|
||||
{
|
||||
ArrayList<Command> commands = new ArrayList<Command>();
|
||||
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
|
||||
commands.add(new CreateFileCommand(c.getName(), c.getRootNodeRef(), c.getPath()));
|
||||
postCommitCommands.add(newOpenFileCallbackCommand());
|
||||
return new CompoundCommand(commands, postCommitCommands);
|
||||
}
|
||||
}
|
||||
else if(operation instanceof OpenFileOperation)
|
||||
{
|
||||
OpenFileOperation o = (OpenFileOperation)operation;
|
||||
name = o.getName();
|
||||
if(name != null)
|
||||
{
|
||||
ArrayList<Command> commands = new ArrayList<Command>();
|
||||
commands.add(new OpenFileCommand(o.getName(), o.getMode(), o.isTruncate(), o.getRootNodeRef(), o.getPath()));
|
||||
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
|
||||
postCommitCommands.add(newOpenFileCallbackCommand());
|
||||
return new CompoundCommand(commands, postCommitCommands);
|
||||
}
|
||||
}
|
||||
|
||||
// Scenario Not Started
|
||||
isComplete = true;
|
||||
@@ -297,7 +304,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
||||
return null;
|
||||
}
|
||||
|
||||
if(name.equalsIgnoreCase(o.getName()))
|
||||
if(name != null && name.equalsIgnoreCase(o.getName()))
|
||||
{
|
||||
if(o.getMode() == OpenFileMode.WRITE)
|
||||
{
|
||||
@@ -313,6 +320,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO Need a permission check here and increment post check
|
||||
openReadWriteCount++;
|
||||
logger.debug("Return already open read/write file handle from scenario:" + this);
|
||||
return new ReturnValueCommand(fileHandleReadWrite);
|
||||
|
Reference in New Issue
Block a user