@@ -33,7 +33,7 @@ func (s *Server) listBranches(w http.ResponseWriter, r *http.Request) {
3333 return
3434 }
3535
36- branches , err := fsm . ListAllBranches ( )
36+ branches , err := s . getAllAvailableBranches ( fsm )
3737 if err != nil {
3838 api .SendBadRequestError (w , r , err .Error ())
3939 return
@@ -85,6 +85,21 @@ func (s *Server) listBranches(w http.ResponseWriter, r *http.Request) {
8585 }
8686}
8787
88+ func (s * Server ) getAllAvailableBranches (fsm pool.FSManager ) ([]models.BranchEntity , error ) {
89+ if fsm == nil {
90+ return nil , fmt .Errorf ("no available pools" )
91+ }
92+
93+ // Filter by available pools in case if two or more DLE is running on the same pool and use the selectedPool feature.
94+ poolNames := []string {}
95+
96+ for _ , fsManager := range s .pm .GetFSManagerList () {
97+ poolNames = append (poolNames , fsManager .Pool ().Name )
98+ }
99+
100+ return fsm .ListAllBranches (poolNames )
101+ }
102+
88103func findBranchParent (snapshots map [string ]models.SnapshotDetails , parentID , branch string ) (int , string ) {
89104 snapshotCounter := 0
90105
@@ -121,13 +136,13 @@ func containsString(slice []string, s string) bool {
121136}
122137
123138func (s * Server ) getFSManagerForBranch (branchName string ) (pool.FSManager , error ) {
124- allBranches , err := s .pm .First (). ListAllBranches ( )
139+ allBranches , err := s .getAllAvailableBranches ( s . pm .First ())
125140 if err != nil {
126141 return nil , fmt .Errorf ("failed to get branch list: %w" , err )
127142 }
128143
129144 for _ , branchEntity := range allBranches {
130- if branchEntity .Name == branchName {
145+ if branchEntity .Name == branchName { // TODO: filter by pool name as well because branch name is ambiguous.
131146 return s .getFSManagerForSnapshot (branchEntity .SnapshotID )
132147 }
133148 }
0 commit comments