fix: collaboration, missing LastModifiedTime
This commit is contained in:
1 parent
1395fe5671
commit
14fafe6691
3 files changed
+24
-2
No files matched your search
@@ -0,0 +1,5 @@
|
||||
Bugfix: Fix collaboration service LastModifiedDate
|
||||
|
||||
Collaboration service now returns correct LastModifiedDate.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/11328
|
||||
@@ -40,6 +40,11 @@ const (
|
||||
// WOPI Locks generally have a lock duration of 30 minutes and will be refreshed before expiration if needed
|
||||
// https://docs.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/concepts#lock
|
||||
lockDuration time.Duration = 30 * time.Minute
|
||||
|
||||
// Expected format for LastModifiedTime is ISO 8601 round-trip format (e.g. "2009-06-15T13:45:30.0000000Z")
|
||||
// see: https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/files/checkfileinfo/checkfileinfo-other#lastmodifiedtime
|
||||
// and: https://pkg.go.dev/time#Time.Format
|
||||
timeFormat = "2006-01-02T15:04:05.0000000Z"
|
||||
)
|
||||
|
||||
// FileConnectorService is the interface to implement the "Files"
|
||||
@@ -1254,10 +1259,16 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
|
||||
}
|
||||
}
|
||||
|
||||
lastModifiedTime := time.Now().UTC().Format(timeFormat)
|
||||
if statRes.GetInfo().GetMtime() != nil {
|
||||
lastModifiedTime = time.Unix(int64(statRes.GetInfo().GetMtime().GetSeconds()), int64(statRes.GetInfo().GetMtime().GetNanos())).UTC().Format(timeFormat)
|
||||
}
|
||||
|
||||
infoMap := map[string]interface{}{
|
||||
fileinfo.KeyOwnerID: hexEncodedOwnerId,
|
||||
fileinfo.KeySize: size,
|
||||
fileinfo.KeyVersion: getVersion(statRes.GetInfo().GetMtime()),
|
||||
fileinfo.KeyLastModifiedTime: lastModifiedTime,
|
||||
fileinfo.KeyBaseFileName: path.Base(statRes.GetInfo().GetPath()),
|
||||
fileinfo.KeyBreadcrumbDocName: path.Base(statRes.GetInfo().GetPath()),
|
||||
// to get the folder we actually need to do a GetPath() request
|
||||
|
||||
@@ -1683,6 +1683,7 @@ var _ = Describe("FileConnector", func() {
|
||||
Size: uint64(998877),
|
||||
Mtime: &typesv1beta1.Timestamp{
|
||||
Seconds: uint64(16273849),
|
||||
Nanos: uint32(123456789),
|
||||
},
|
||||
Path: "/path/to/test.txt",
|
||||
Id: &providerv1beta1.ResourceId{
|
||||
@@ -1701,7 +1702,8 @@ var _ = Describe("FileConnector", func() {
|
||||
expectedFileInfo := &fileinfo.Microsoft{
|
||||
OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp
|
||||
Size: int64(998877),
|
||||
Version: "v162738490",
|
||||
Version: "v16273849123456789",
|
||||
LastModifiedTime: "1970-07-08T08:30:49.1234567Z",
|
||||
BaseFileName: "test.txt",
|
||||
BreadcrumbDocName: "test.txt",
|
||||
BreadcrumbFolderName: "/path/to",
|
||||
@@ -1757,6 +1759,7 @@ var _ = Describe("FileConnector", func() {
|
||||
Size: uint64(998877),
|
||||
Mtime: &typesv1beta1.Timestamp{
|
||||
Seconds: uint64(16273849),
|
||||
Nanos: uint32(1234567),
|
||||
},
|
||||
Path: "/path/to/test.txt",
|
||||
Id: &providerv1beta1.ResourceId{
|
||||
@@ -1859,6 +1862,7 @@ var _ = Describe("FileConnector", func() {
|
||||
Size: uint64(998877),
|
||||
Mtime: &typesv1beta1.Timestamp{
|
||||
Seconds: uint64(16273849),
|
||||
Nanos: uint32(123456789),
|
||||
},
|
||||
Path: "/path/to/test.txt",
|
||||
Id: ResourceId,
|
||||
@@ -1876,7 +1880,8 @@ var _ = Describe("FileConnector", func() {
|
||||
cfg.App.Product = "OnlyOffice"
|
||||
|
||||
expectedFileInfo := &fileinfo.OnlyOffice{
|
||||
Version: "v162738490",
|
||||
Version: "v16273849123456789",
|
||||
LastModifiedTime: "1970-07-08T08:30:49.1234567Z",
|
||||
Size: conversions.ToPointer(int64(998877)),
|
||||
BaseFileName: "test.txt",
|
||||
BreadcrumbDocName: "test.txt",
|
||||
@@ -2031,6 +2036,7 @@ var _ = Describe("FileConnector", func() {
|
||||
|
||||
expectedFileInfo := &fileinfo.OnlyOffice{
|
||||
Version: "v162738490",
|
||||
LastModifiedTime: "1970-07-08T08:30:49.0000000Z",
|
||||
BaseFileName: "test.txt",
|
||||
BreadcrumbDocName: "test.txt",
|
||||
BreadcrumbFolderName: "/path/to",
|
||||
|
||||
Reference in new issue
Block a user