Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/org/filesys/server/filesys/NetworkFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public enum Flags {
protected long m_modifyDate;
protected long m_accessDate;

// Track whether file date needs updating on file close
protected boolean m_modifyDateDirty;

// Granted file access type
protected Access m_grantedAccess;

Expand Down Expand Up @@ -566,6 +569,17 @@ public final long getModifyDate() {
return m_modifyDate;
}

/**
* Return whether the file modify date/time is dirty due to file writes. Calling
* {@link incrementWriteCount} marks the modify date/time as dirty, setting the
* date/time via {@link setModifyDate} resets it back to clean.
*
* @return boolean
*/
public final boolean isModifyDateDirty() {
return m_modifyDateDirty;
}

/**
* Get the write count for the file
*
Expand All @@ -580,6 +594,7 @@ public final int getWriteCount() {
*/
public final void incrementWriteCount() {
m_writeCount++;
m_modifyDateDirty = true;
}

/**
Expand Down Expand Up @@ -799,6 +814,7 @@ public final void setDelayedClose(boolean delayClose) {
*/
public final void setModifyDate(long dattim) {
m_modifyDate = dattim;
m_modifyDateDirty = false;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/filesys/server/filesys/db/DBDiskDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1488,8 +1488,12 @@ public void setFileInformation(SrvSession sess, TreeConnection tree, String name
if (info.hasSetFlag(FileInfo.SetCreationDate))
dbInfo.setAccessDateTime(info.getCreationDateTime());

if (info.hasSetFlag(FileInfo.SetModifyDate))
dbInfo.setAccessDateTime(info.getModifyDateTime());
if (info.hasSetFlag(FileInfo.SetModifyDate)) {
long modifyDate = info.getModifyDateTime();
dbInfo.setAccessDateTime(modifyDate);
if (info.hasNetworkFile())
info.getNetworkFile().setModifyDate(modifyDate);
}

if (info.hasSetFlag(FileInfo.SetChangeDate))
dbInfo.setAccessDateTime(info.getChangeDateTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ public void closeFile() {
m_io = null;

// Set the last modified date/time for the file
if (this.getWriteCount() > 0)
m_file.setLastModified(System.currentTimeMillis());
if (this.isModifyDateDirty()) {
long curTime = System.currentTimeMillis();
m_file.setLastModified(curTime);
this.setModifyDate(curTime);
}

// Set the new file size
setFileSize(m_file.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ public void closeFile()
m_io = null;

// Set the last modified date/time for the file
if (this.getWriteCount() > 0)
m_file.setLastModified(System.currentTimeMillis());
if (this.isModifyDateDirty()) {
long curTime = System.currentTimeMillis();
m_file.setLastModified(curTime);
this.setModifyDate(curTime);
}

// Indicate that the file is closed
setClosed(true);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/filesys/smb/server/CoreProtocolHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,9 @@ protected void procSetFileInformation(SMBSrvPacket smbPkt, SMBV1Parser parser)
// Access the disk interface that is associated with the shared device
DiskInterface disk = (DiskInterface) conn.getSharedDevice().getInterface();

// Store the associated network file in the file information object
finfo.setNetworkFile(netFile);

// Get the file information for the specified file/directory
finfo.setFileInformationFlags(setFlags);
disk.setFileInformation(m_sess, conn, netFile.getFullName(), finfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,10 @@ public void setFileInformation(SrvSession sess, TreeConnection tree, String name

// Update the file/folder modify date/time
Files.setLastModifiedTime( filePath, FileTime.fromMillis( info.getModifyDateTime()));

// Update the associated network file, too, if possible
if (info.hasNetworkFile())
info.getNetworkFile().setModifyDate(info.getModifyDateTime());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ public void closeFile() throws IOException {
m_io = null;

// Set the last modified date/time for the file
if (this.getWriteCount() > 0)
Files.setLastModifiedTime(m_path, FileTime.fromMillis( System.currentTimeMillis()));
if (this.isModifyDateDirty()) {
long curTime = System.currentTimeMillis();
Files.setLastModifiedTime(m_path, FileTime.fromMillis(curTime));
this.setModifyDate(curTime);
}

// Indicate that the file is closed
setClosed(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ public void setFileInformation(SrvSession<?> sess, TreeConnection tree, String n
// Update the file/folder modify date/time
File file = new File(fname);
file.setLastModified(info.getModifyDateTime());

// Update the associated network file, too, if possible
if (info.hasNetworkFile())
info.getNetworkFile().setModifyDate(info.getModifyDateTime());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ public void closeFile() throws IOException {
m_io = null;

// Set the last modified date/time for the file
if (this.getWriteCount() > 0)
m_file.setLastModified(System.currentTimeMillis());
if (this.isModifyDateDirty()) {
long curTime = System.currentTimeMillis();
m_file.setLastModified(curTime);
this.setModifyDate(curTime);
}

// Indicate that the file is closed
setClosed(true);
Expand Down