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())
|
if(tctx.hasStateCache())
|
||||||
{
|
{
|
||||||
FileStateCache cache = tctx.getStateCache();
|
FileStateCache cache = tctx.getStateCache();
|
||||||
FileState fstate = tctx.getStateCache().findFileState(path, false);
|
FileState fstate = cache.findFileState(path, false);
|
||||||
if(fstate != null)
|
if(fstate != null)
|
||||||
{
|
{
|
||||||
FileInfo finfo = new FileInfo();
|
FileInfo finfo = new FileInfo();
|
||||||
finfo.copyFrom(info);
|
finfo.copyFrom(info);
|
||||||
|
|
||||||
|
// TODO what if file state cache is stale or wrong? We are over-writing the "real" value.
|
||||||
if(fstate.hasFileSize())
|
if(fstate.hasFileSize())
|
||||||
{
|
{
|
||||||
finfo.setFileSize(fstate.getFileSize());
|
finfo.setFileSize(fstate.getFileSize());
|
||||||
@@ -253,9 +254,23 @@ public class BufferedContentDiskDriver implements ExtendedDiskInterface,
|
|||||||
finfo.setAllocationSize( fstate.getAllocationSize());
|
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;
|
return finfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("getFileInformation returning:" + path + " returning" + info);
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
|
@@ -198,6 +198,7 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
|
|||||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||||
x.setFileState(fstate);
|
x.setFileState(fstate);
|
||||||
fstate.setProcessId(params.getProcessId());
|
fstate.setProcessId(params.getProcessId());
|
||||||
|
fstate.setSharedAccess( params.getSharedAccess());
|
||||||
fstate.setFileStatus(FileStatus.FileExists);
|
fstate.setFileStatus(FileStatus.FileExists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,6 +213,8 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
|
|||||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||||
x.setFileState(fstate);
|
x.setFileState(fstate);
|
||||||
fstate.setFileStatus(FileStatus.FileExists);
|
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);
|
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||||
x.setFileState(fstate);
|
x.setFileState(fstate);
|
||||||
fstate.setFileStatus(FileStatus.DirectoryExists);
|
fstate.setFileStatus(FileStatus.DirectoryExists);
|
||||||
|
fstate.setProcessId(params.getProcessId());
|
||||||
|
fstate.setSharedAccess( params.getSharedAccess());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,39 +67,46 @@ public class TempNetworkFile extends JavaNetworkFile implements NetworkFileState
|
|||||||
@Override
|
@Override
|
||||||
public void writeFile(byte[] buf, int len, int pos) throws IOException
|
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)
|
if(fileState != null)
|
||||||
{
|
{
|
||||||
fileState.updateModifyDateTime();
|
fileState.updateModifyDateTime();
|
||||||
|
fileState.setFileSize(size);
|
||||||
}
|
}
|
||||||
super.writeFile(buf, len, pos);
|
|
||||||
|
|
||||||
setFileSize(m_io.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeFile(byte[] buffer, int length, int position, long fileOffset)
|
public void writeFile(byte[] buffer, int length, int position, long fileOffset)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if(fileState != null)
|
|
||||||
{
|
|
||||||
fileState.updateModifyDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.writeFile(buffer, length, position, fileOffset);
|
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
|
@Override
|
||||||
public void truncateFile(long size) throws IOException
|
public void truncateFile(long size) throws IOException
|
||||||
{
|
{
|
||||||
if(fileState != null)
|
|
||||||
{
|
|
||||||
fileState.updateModifyDateTime();
|
|
||||||
}
|
|
||||||
super.truncateFile(size);
|
super.truncateFile(size);
|
||||||
|
|
||||||
setFileSize(size);
|
setFileSize(size);
|
||||||
|
if(fileState != null)
|
||||||
|
{
|
||||||
|
fileState.updateModifyDateTime();
|
||||||
|
fileState.setFileSize(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For JLAN file state lock manager
|
// For JLAN file state lock manager
|
||||||
|
@@ -150,21 +150,28 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
|||||||
{
|
{
|
||||||
CreateFileOperation c = (CreateFileOperation)operation;
|
CreateFileOperation c = (CreateFileOperation)operation;
|
||||||
name = c.getName();
|
name = c.getName();
|
||||||
ArrayList<Command> commands = new ArrayList<Command>();
|
|
||||||
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
|
if(name != null)
|
||||||
commands.add(new CreateFileCommand(c.getName(), c.getRootNodeRef(), c.getPath()));
|
{
|
||||||
postCommitCommands.add(newOpenFileCallbackCommand());
|
ArrayList<Command> commands = new ArrayList<Command>();
|
||||||
return new CompoundCommand(commands, postCommitCommands);
|
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)
|
else if(operation instanceof OpenFileOperation)
|
||||||
{
|
{
|
||||||
OpenFileOperation o = (OpenFileOperation)operation;
|
OpenFileOperation o = (OpenFileOperation)operation;
|
||||||
name = o.getName();
|
name = o.getName();
|
||||||
ArrayList<Command> commands = new ArrayList<Command>();
|
if(name != null)
|
||||||
commands.add(new OpenFileCommand(o.getName(), o.getMode(), o.isTruncate(), o.getRootNodeRef(), o.getPath()));
|
{
|
||||||
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
|
ArrayList<Command> commands = new ArrayList<Command>();
|
||||||
postCommitCommands.add(newOpenFileCallbackCommand());
|
commands.add(new OpenFileCommand(o.getName(), o.getMode(), o.isTruncate(), o.getRootNodeRef(), o.getPath()));
|
||||||
return new CompoundCommand(commands, postCommitCommands);
|
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
|
||||||
|
postCommitCommands.add(newOpenFileCallbackCommand());
|
||||||
|
return new CompoundCommand(commands, postCommitCommands);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scenario Not Started
|
// Scenario Not Started
|
||||||
@@ -297,7 +304,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name.equalsIgnoreCase(o.getName()))
|
if(name != null && name.equalsIgnoreCase(o.getName()))
|
||||||
{
|
{
|
||||||
if(o.getMode() == OpenFileMode.WRITE)
|
if(o.getMode() == OpenFileMode.WRITE)
|
||||||
{
|
{
|
||||||
@@ -313,6 +320,7 @@ class ScenarioOpenFileInstance implements ScenarioInstance
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// TODO Need a permission check here and increment post check
|
||||||
openReadWriteCount++;
|
openReadWriteCount++;
|
||||||
logger.debug("Return already open read/write file handle from scenario:" + this);
|
logger.debug("Return already open read/write file handle from scenario:" + this);
|
||||||
return new ReturnValueCommand(fileHandleReadWrite);
|
return new ReturnValueCommand(fileHandleReadWrite);
|
||||||
|
Reference in New Issue
Block a user