mirror of
				https://github.com/cloudreve/cloudreve.git
				synced 2025-11-04 04:47:24 +08:00 
			
		
		
		
	Fix: slave node cannot transfer files to other slave node
This commit is contained in:
		@ -247,9 +247,6 @@ func (fs *FileSystem) SwitchToSlaveHandler(node cluster.Node) {
 | 
				
			|||||||
// SwitchToShadowHandler 将负责上传的 Handler 切换为从机节点转存使用的影子处理器
 | 
					// SwitchToShadowHandler 将负责上传的 Handler 切换为从机节点转存使用的影子处理器
 | 
				
			||||||
func (fs *FileSystem) SwitchToShadowHandler(master cluster.Node, masterURL, masterID string) {
 | 
					func (fs *FileSystem) SwitchToShadowHandler(master cluster.Node, masterURL, masterID string) {
 | 
				
			||||||
	switch fs.Policy.Type {
 | 
						switch fs.Policy.Type {
 | 
				
			||||||
	case "remote":
 | 
					 | 
				
			||||||
		fs.Policy.Type = "local"
 | 
					 | 
				
			||||||
		fs.DispatchHandler()
 | 
					 | 
				
			||||||
	case "local":
 | 
						case "local":
 | 
				
			||||||
		fs.Policy.Type = "remote"
 | 
							fs.Policy.Type = "remote"
 | 
				
			||||||
		fs.Policy.Server = masterURL
 | 
							fs.Policy.Server = masterURL
 | 
				
			||||||
 | 
				
			|||||||
@ -292,17 +292,17 @@ func TestFileSystem_SwitchToShadowHandler(t *testing.T) {
 | 
				
			|||||||
		Model: &model.Node{},
 | 
							Model: &model.Node{},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// remote to local
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		fs.Policy.Type = "remote"
 | 
					 | 
				
			||||||
		fs.SwitchToShadowHandler(mockNode, "", "")
 | 
					 | 
				
			||||||
		a.IsType(&masterinslave.Driver{}, fs.Handler)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// local to remote
 | 
						// local to remote
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		fs.Policy.Type = "local"
 | 
							fs.Policy.Type = "local"
 | 
				
			||||||
		fs.SwitchToShadowHandler(mockNode, "", "")
 | 
							fs.SwitchToShadowHandler(mockNode, "", "")
 | 
				
			||||||
		a.IsType(&masterinslave.Driver{}, fs.Handler)
 | 
							a.IsType(&masterinslave.Driver{}, fs.Handler)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// onedrive
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							fs.Policy.Type = "onedrive"
 | 
				
			||||||
 | 
							fs.SwitchToShadowHandler(mockNode, "", "")
 | 
				
			||||||
 | 
							a.IsType(&masterinslave.Driver{}, fs.Handler)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user