Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #289 from tobespc/addTimeNow
Browse files Browse the repository at this point in the history
[0.7.0] ensure current sync time is sent
  • Loading branch information
tobespc authored Dec 13, 2019
2 parents d3c8386 + 1462e0c commit 8524074
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/project/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"path"
"path/filepath"
"strings"
"time"

"github.com/eclipse/codewind-installer/pkg/config"
"github.com/eclipse/codewind-installer/pkg/connections"
Expand Down Expand Up @@ -63,6 +64,7 @@ type (

// SyncProject syncs a project with its remote connection
func SyncProject(c *cli.Context) (*SyncResponse, *ProjectError) {
var currentSyncTime = time.Now().UnixNano() / 1000000;
projectPath := strings.TrimSpace(c.String("path"))
projectID := strings.TrimSpace(c.String("id"))
synctime := int64(c.Int("time"))
Expand Down Expand Up @@ -95,7 +97,7 @@ func SyncProject(c *cli.Context) (*SyncResponse, *ProjectError) {
// Sync all the necessary project files
fileList, modifiedList, uploadedFilesList := syncFiles(projectPath, projectID, conURL, synctime, conInfo)
// Complete the upload
completeStatus, completeStatusCode := completeUpload(projectID, fileList, modifiedList, conID, synctime)
completeStatus, completeStatusCode := completeUpload(projectID, fileList, modifiedList, conID, currentSyncTime)
response := SyncResponse{
UploadedFiles: uploadedFilesList,
Status: completeStatus,
Expand Down Expand Up @@ -194,7 +196,7 @@ func syncFiles(projectPath string, projectID string, conURL string, synctime int
return fileList, modifiedList, uploadedFiles
}

func completeUpload(projectID string, files []string, modfiles []string, conID string, timestamp int64) (string, int) {
func completeUpload(projectID string, files []string, modfiles []string, conID string, currentSyncTime int64) (string, int) {

conInfo, conInfoErr := connections.GetConnectionByID(conID)
if conInfoErr != nil {
Expand All @@ -208,7 +210,7 @@ func completeUpload(projectID string, files []string, modfiles []string, conID s

uploadEndURL := conURL + "/api/v1/projects/" + projectID + "/upload/end"

payload := &CompleteRequest{FileList: files, ModifiedList: modfiles, TimeStamp: timestamp}
payload := &CompleteRequest{FileList: files, ModifiedList: modfiles, TimeStamp: currentSyncTime}
jsonPayload, _ := json.Marshal(payload)

req, err := http.NewRequest("POST", uploadEndURL, bytes.NewBuffer(jsonPayload))
Expand Down

0 comments on commit 8524074

Please sign in to comment.