|
1 | 1 | // Copyright 2025 CloudWeGo Authors
|
2 |
| -// |
| 2 | +// |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | // you may not use this file except in compliance with the License.
|
5 | 5 | // You may obtain a copy of the License at
|
6 |
| -// |
| 6 | +// |
7 | 7 | // https://www.apache.org/licenses/LICENSE-2.0
|
8 |
| -// |
| 8 | +// |
9 | 9 | // Unless required by applicable law or agreed to in writing, software
|
10 | 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
11 | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -40,7 +40,11 @@ pub fn from_json(id: &str, json: &str) -> Result<Repository, Box<dyn Error>> {
|
40 | 40 | f.id = id.to_string();
|
41 | 41 | }
|
42 | 42 | if f.graph.is_none() {
|
43 |
| - f.build_graph(); |
| 43 | + //return err |
| 44 | + return Err(Box::new(std::io::Error::new( |
| 45 | + std::io::ErrorKind::Other, |
| 46 | + "graph is None", |
| 47 | + ))); |
44 | 48 | }
|
45 | 49 | f.save_to_cache();
|
46 | 50 | Ok(f)
|
@@ -171,18 +175,20 @@ pub async fn cascade_compress_variable(
|
171 | 175 | return;
|
172 | 176 | }
|
173 | 177 | let var_node = var_node.unwrap();
|
174 |
| - for (i, v) in var_node.references.iter().enumerate() { |
175 |
| - if i >= MAX_REFERS { |
176 |
| - eprintln!("too many references for {:?}", id); |
177 |
| - break; |
178 |
| - } |
179 |
| - let c = repo.get_id_content(v); |
180 |
| - if c.is_none() { |
181 |
| - eprintln!("{:?} node is not found", v); |
182 |
| - continue; |
| 178 | + if let Some(nfs) = &var_node.references { |
| 179 | + for (i, v) in nfs.iter().enumerate() { |
| 180 | + if i >= MAX_REFERS { |
| 181 | + eprintln!("too many references for {:?}", id); |
| 182 | + break; |
| 183 | + } |
| 184 | + let c = repo.get_id_content(&v.id()); |
| 185 | + if c.is_none() { |
| 186 | + eprintln!("{:?} node is not found", v); |
| 187 | + continue; |
| 188 | + } |
| 189 | + let elem = c.unwrap(); |
| 190 | + refs.push(elem); |
183 | 191 | }
|
184 |
| - let elem = c.unwrap(); |
185 |
| - refs.push(elem); |
186 | 192 | }
|
187 | 193 |
|
188 | 194 | // compress type if any
|
|
0 commit comments