Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Return collection files addedAt

Neeraj Gupta34ed944bf826
diff --git a/server/ente/file.go b/server/ente/file.go
index 3a603773a6..dc1be934cb 100644
--- a/server/ente/file.go
+++ b/server/ente/file.go
@@ -9,24 +9,25 @@ import (
// File represents an encrypted file in the system
type File struct {
- ID int64 `json:"id"`
- OwnerID int64 `json:"ownerID"`
- CollectionID int64 `json:"collectionID"`
- CollectionOwnerID *int64 `json:"collectionOwnerID"`
- EncryptedKey string `json:"encryptedKey"`
- KeyDecryptionNonce string `json:"keyDecryptionNonce"`
- File FileAttributes `json:"file" binding:"required"`
- Thumbnail FileAttributes `json:"thumbnail" binding:"required"`
- Metadata FileAttributes `json:"metadata" binding:"required"`
- // IsDeleted is True when the file ID is removed from the CollectionID
- IsDeleted bool `json:"isDeleted"`
- UpdationTime int64 `json:"updationTime"`
- MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`
- PubicMagicMetadata *MagicMetadata `json:"pubMagicMetadata,omitempty"`
- Info *FileInfo `json:"info,omitempty"`
- // Action and ActionUser are optionally set to drive client-side behavior during diffs
- Action *string `json:"action,omitempty"`
- ActionUserID *int64 `json:"actionUser,omitempty"`
+ ID int64 `json:"id"`
+ OwnerID int64 `json:"ownerID"`
+ CollectionID int64 `json:"collectionID"`
+ CollectionOwnerID *int64 `json:"collectionOwnerID"`
+ CollectionAddedAt *int64 `json:"collectionAddedAt,omitempty"`
+ EncryptedKey string `json:"encryptedKey"`
+ KeyDecryptionNonce string `json:"keyDecryptionNonce"`
+ File FileAttributes `json:"file" binding:"required"`
+ Thumbnail FileAttributes `json:"thumbnail" binding:"required"`
+ Metadata FileAttributes `json:"metadata" binding:"required"`
+ // IsDeleted is True when the file ID is removed from the CollectionID
+ IsDeleted bool `json:"isDeleted"`
+ UpdationTime int64 `json:"updationTime"`
+ MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`
+ PubicMagicMetadata *MagicMetadata `json:"pubMagicMetadata,omitempty"`
+ Info *FileInfo `json:"info,omitempty"`
+ // Action and ActionUser are optionally set to drive client-side behavior during diffs
+ Action *string `json:"action,omitempty"`
+ ActionUserID *int64 `json:"actionUser,omitempty"`
}
type MetaFile struct {
diff --git a/server/pkg/repo/collection.go b/server/pkg/repo/collection.go
index b683d47597..df14122327 100644
--- a/server/pkg/repo/collection.go
+++ b/server/pkg/repo/collection.go
@@ -839,7 +839,7 @@ func (repo *CollectionRepository) GetDiff(collectionID int64, sinceTime int64, l
collection_files.encrypted_key, collection_files.key_decryption_nonce,
files.file_decryption_header, files.thumbnail_decryption_header,
files.metadata_decryption_header, files.encrypted_metadata, files.magic_metadata, files.pub_magic_metadata,
- files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time
+ files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time, collection_files.created_at
FROM files
INNER JOIN collection_files
ON collection_files.file_id = files.file_id
@@ -864,7 +864,7 @@ func (repo *CollectionRepository) GetFilesWithVersion(collectionID int64, update
collection_files.encrypted_key, collection_files.key_decryption_nonce,
files.file_decryption_header, files.thumbnail_decryption_header,
files.metadata_decryption_header, files.encrypted_metadata, files.magic_metadata, files.pub_magic_metadata,
- files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time
+ files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time, collection_files.created_at
FROM files
INNER JOIN collection_files
ON collection_files.file_id = files.file_id
@@ -883,7 +883,7 @@ func (repo *CollectionRepository) GetFile(collectionID int64, fileID int64) ([]e
collection_files.encrypted_key, collection_files.key_decryption_nonce,
files.file_decryption_header, files.thumbnail_decryption_header,
files.metadata_decryption_header, files.encrypted_metadata, files.magic_metadata, files.pub_magic_metadata,
- files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time
+ files.info, collection_files.action_user, collection_files.action, collection_files.is_deleted, collection_files.updation_time, collection_files.created_at
FROM files
INNER JOIN collection_files
ON collection_files.file_id = files.file_id
diff --git a/server/pkg/repo/file.go b/server/pkg/repo/file.go
index 7d0cb3475a..1236ef9c6f 100644
--- a/server/pkg/repo/file.go
+++ b/server/pkg/repo/file.go
@@ -1,12 +1,12 @@
package repo
import (
- "context"
- "database/sql"
- "errors"
- "fmt"
- "strconv"
- "strings"
+ "context"
+ "database/sql"
+ "errors"
+ "fmt"
+ "strconv"
+ "strings"
"github.com/ente-io/stacktrace"
log "github.com/sirupsen/logrus"
@@ -814,36 +814,41 @@ func (repo *FileRepository) GetTotalFileCount() (int64, error) {
}
func convertRowsToFiles(rows *sql.Rows) ([]ente.File, error) {
- defer rows.Close()
- files := make([]ente.File, 0)
- for rows.Next() {
- var (
- file ente.File
- updationTime float64
- actionUser sql.NullInt64
- action sql.NullString
- )
- err := rows.Scan(&file.ID, &file.OwnerID, &file.CollectionID, &file.CollectionOwnerID,
- &file.EncryptedKey, &file.KeyDecryptionNonce,
- &file.File.DecryptionHeader, &file.Thumbnail.DecryptionHeader,
- &file.Metadata.DecryptionHeader,
- &file.Metadata.EncryptedData, &file.MagicMetadata, &file.PubicMagicMetadata,
- &file.Info, &actionUser, &action, &file.IsDeleted, &updationTime)
- if err != nil {
- return files, stacktrace.Propagate(err, "")
- }
- if actionUser.Valid {
- v := actionUser.Int64
- file.ActionUserID = &v
- }
- if action.Valid {
- v := action.String
- file.Action = &v
- }
- file.UpdationTime = int64(updationTime)
- files = append(files, file)
- }
- return files, nil
+ defer rows.Close()
+ files := make([]ente.File, 0)
+ for rows.Next() {
+ var (
+ file ente.File
+ updationTime float64
+ actionUser sql.NullInt64
+ action sql.NullString
+ addedAt sql.NullInt64
+ )
+ err := rows.Scan(&file.ID, &file.OwnerID, &file.CollectionID, &file.CollectionOwnerID,
+ &file.EncryptedKey, &file.KeyDecryptionNonce,
+ &file.File.DecryptionHeader, &file.Thumbnail.DecryptionHeader,
+ &file.Metadata.DecryptionHeader,
+ &file.Metadata.EncryptedData, &file.MagicMetadata, &file.PubicMagicMetadata,
+ &file.Info, &actionUser, &action, &file.IsDeleted, &updationTime, &addedAt)
+ if err != nil {
+ return files, stacktrace.Propagate(err, "")
+ }
+ if actionUser.Valid {
+ v := actionUser.Int64
+ file.ActionUserID = &v
+ }
+ if action.Valid {
+ v := action.String
+ file.Action = &v
+ }
+ file.UpdationTime = int64(updationTime)
+ if addedAt.Valid {
+ v := addedAt.Int64
+ file.CollectionAddedAt = &v
+ }
+ files = append(files, file)
+ }
+ return files, nil
}
// scheduleDeletion added a list of files's object ids to delete queue for deletion from datastore