1
1
use crate :: {
2
2
error:: Result ,
3
- sync:: { self , CommitId } ,
4
- AsyncGitNotification , StatusItem , CWD ,
3
+ sync:: { self , CommitId , RepoPath } ,
4
+ AsyncGitNotification , StatusItem ,
5
5
} ;
6
6
use crossbeam_channel:: Sender ;
7
7
use std:: sync:: {
@@ -42,12 +42,17 @@ pub struct AsyncCommitFiles {
42
42
Arc < Mutex < Option < Request < CommitFilesParams , ResultType > > > > ,
43
43
sender : Sender < AsyncGitNotification > ,
44
44
pending : Arc < AtomicUsize > ,
45
+ repo : RepoPath ,
45
46
}
46
47
47
48
impl AsyncCommitFiles {
48
49
///
49
- pub fn new ( sender : & Sender < AsyncGitNotification > ) -> Self {
50
+ pub fn new (
51
+ repo : RepoPath ,
52
+ sender : & Sender < AsyncGitNotification > ,
53
+ ) -> Self {
50
54
Self {
55
+ repo,
51
56
current : Arc :: new ( Mutex :: new ( None ) ) ,
52
57
sender : sender. clone ( ) ,
53
58
pending : Arc :: new ( AtomicUsize :: new ( 0 ) ) ,
@@ -89,11 +94,12 @@ impl AsyncCommitFiles {
89
94
let arc_current = Arc :: clone ( & self . current ) ;
90
95
let sender = self . sender . clone ( ) ;
91
96
let arc_pending = Arc :: clone ( & self . pending ) ;
97
+ let repo = self . repo . clone ( ) ;
92
98
93
99
self . pending . fetch_add ( 1 , Ordering :: Relaxed ) ;
94
100
95
101
rayon_core:: spawn ( move || {
96
- Self :: fetch_helper ( params, & arc_current)
102
+ Self :: fetch_helper ( & repo , params, & arc_current)
97
103
. expect ( "failed to fetch" ) ;
98
104
99
105
arc_pending. fetch_sub ( 1 , Ordering :: Relaxed ) ;
@@ -107,13 +113,17 @@ impl AsyncCommitFiles {
107
113
}
108
114
109
115
fn fetch_helper (
116
+ repo_path : & RepoPath ,
110
117
params : CommitFilesParams ,
111
118
arc_current : & Arc <
112
119
Mutex < Option < Request < CommitFilesParams , ResultType > > > ,
113
120
> ,
114
121
) -> Result < ( ) > {
115
- let res =
116
- sync:: get_commit_files ( CWD , params. id , params. other ) ?;
122
+ let res = sync:: get_commit_files (
123
+ repo_path,
124
+ params. id ,
125
+ params. other ,
126
+ ) ?;
117
127
118
128
log:: trace!( "get_commit_files: {:?} ({})" , params, res. len( ) ) ;
119
129
0 commit comments