mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
refactor create session
This commit is contained in:
parent
8d2c40f1ce
commit
23fe54ce0b
@ -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())
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user