refactor create session

This commit is contained in:
tickstep 2023-04-02 09:37:42 +08:00
parent 8d2c40f1ce
commit 23fe54ce0b
6 changed files with 48 additions and 15 deletions

View File

@ -169,10 +169,7 @@ func RefreshTokenInNeed(activeUser *config.PanUser, deviceName string) bool {
}
// create new signature
_, e := activeUser.PanClient().CreateSession(&aliyunpan.CreateSessionParam{
DeviceName: deviceName,
ModelName: "Windows网页版",
})
_, e := activeUser.PanClient().CreateSession(nil)
if e != nil {
logger.Verboseln("call CreateSession error in RefreshTokenInNeed: " + e.Error())
}

View File

@ -87,7 +87,10 @@ doLoginAct:
Nonce: 0,
PublicKey: "",
}
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, appConfig)
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, appConfig, aliyunpan.SessionConfig{
DeviceName: deviceName,
ModelName: "Windows网页版",
})
u := &PanUser{
WebToken: *webToken,
panClient: panClient,
@ -137,10 +140,7 @@ doLoginAct:
// create session
appConfig.UserId = u.UserId
panClient.UpdateAppConfig(appConfig)
r, e := panClient.CreateSession(&aliyunpan.CreateSessionParam{
DeviceName: deviceName,
ModelName: "Windows网页版",
})
r, e := panClient.CreateSession(nil)
if e != nil {
logger.Verboseln("call CreateSession error in SetupUserByCookie: " + e.Error())
}

View File

@ -19,7 +19,16 @@ func TestFileActionMgrStart(t *testing.T) {
}
// pan client
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
AppId: "25dzX3vbYqktVxyX",
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
UserId: "",
Nonce: 0,
PublicKey: "",
}, aliyunpan.SessionConfig{
DeviceName: "Chrome浏览器",
ModelName: "Windows网页版",
})
user, _ := panClient.GetUserInfo()
task := &SyncTask{
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",

View File

@ -25,7 +25,16 @@ func TestPanSyncDb(t *testing.T) {
}
// pan client
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
AppId: "25dzX3vbYqktVxyX",
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
UserId: "",
Nonce: 0,
PublicKey: "",
}, aliyunpan.SessionConfig{
DeviceName: "Chrome浏览器",
ModelName: "Windows网页版",
})
// get user info
ui, err := panClient.GetUserInfo()

View File

@ -16,7 +16,16 @@ func TestStart(t *testing.T) {
}
// pan client
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
AppId: "25dzX3vbYqktVxyX",
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
UserId: "",
Nonce: 0,
PublicKey: "",
}, aliyunpan.SessionConfig{
DeviceName: "Chrome浏览器",
ModelName: "Windows网页版",
})
user, _ := panClient.GetUserInfo()
manager := NewSyncTaskManager(
@ -27,7 +36,7 @@ func TestStart(t *testing.T) {
SyncOption{},
)
manager.Start(nil)
manager.Start(nil, StepSyncFile)
time.Sleep(30 * time.Minute)
manager.Stop()
manager.Stop(StepSyncFile)
}

View File

@ -17,7 +17,16 @@ func TestSyncTask(t *testing.T) {
}
// pan client
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{})
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
AppId: "25dzX3vbYqktVxyX",
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
UserId: "",
Nonce: 0,
PublicKey: "",
}, aliyunpan.SessionConfig{
DeviceName: "Chrome浏览器",
ModelName: "Windows网页版",
})
user, _ := panClient.GetUserInfo()
task := SyncTask{
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",