2121# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222
2323import logging
24+ < << << << HEAD
25+ == == == =
26+ from pathlib import Path
27+ > >> >> >> ca3a1ac0c0147a6f3f59999a67bf586eab9b8a36
2428from aboutcode .pipeline import optional_step
29+ from aboutcode .pipeline import group
2530from scanpipe .pipelines .scan_codebase import ScanCodebase
2631from scanpipe .pipes import resolve
2732from scanpipe .pipes import scancode
@@ -61,7 +66,36 @@ def get_manifest_inputs(self):
6166 """Locate package manifest files with a supported package resolver."""
6267 self .manifest_resources = resolve .get_manifest_resources (self .project )
6368
64- @optional_step ("StaticResolver" )
69+ def store_manifest_files (self ):
70+ """Store manifest files locally if enabled."""
71+ if not self .project .use_local_storage :
72+ logger .info (f"Local storage is disabled for project: { self .project .name } ."
73+ "Skipping file storage." )
74+ return []
75+
76+ logger .info (f"Storing manifest files for project: { self .project .name } " )
77+ stored_files = []
78+
79+ for resource in self .manifest_resources :
80+ resource_path = resource .path
81+ if not Path (resource_path ).exists ():
82+ logger .error (f"Invalid or missing file path: { resource_path } " )
83+ continue
84+ resource_path_str = str (resource_path )
85+ logger .info (f"Storing manifest file: { resource_path_str } " )
86+ try :
87+ result = store_package_archive (
88+ self .project , url = None , file_path = resource_path_str
89+ )
90+ logger .info (f"Stored manifest file { resource_path_str } : { result } " )
91+ stored_files .append (result )
92+ except Exception as e :
93+ logger .error (f"Failed to store { resource_path_str } : { e } " )
94+
95+ return stored_files
96+
97+
98+ @group ("StaticResolver" )
6599 def scan_for_application_packages (self ):
66100 """
67101 Scan and assemble application packages from package manifests
@@ -74,7 +108,42 @@ def scan_for_application_packages(self):
74108 progress_logger = self .log ,
75109 )
76110
77- @optional_step ("StaticResolver" )
111+ def store_package_archives (self ):
112+ """Store package archives locally if enabled."""
113+ if not self .project .use_local_storage :
114+ logger .info (f"Local storage is disabled for project: { self .project .name } ."
115+ "Skipping package storage." )
116+ return []
117+
118+ logger .info (f"Storing package archives for project: { self .project .name } " )
119+ stored_files = []
120+ package_files = [
121+ resource .path
122+ for resource in self .project .codebaseresources .filter (
123+ extension__in = [
124+ ".whl" , ".tar.gz" , ".zip" , ".deb" , ".rpm" , ".apk" , ".nupkg"
125+ ]
126+ )
127+ ]
128+
129+ for package_path in package_files :
130+ if not Path (package_path ).exists ():
131+ logger .error (f"Invalid or missing package path: { package_path } " )
132+ continue
133+ package_path_str = str (package_path )
134+ logger .info (f"Storing package archive: { package_path_str } " )
135+ try :
136+ result = store_package_archive (
137+ self .project , url = None , file_path = package_path_str
138+ )
139+ logger .info (f"Stored package archive { package_path_str } : { result } " )
140+ stored_files .append (result )
141+ except Exception as e :
142+ logger .error (f"Failed to store { package_path_str } : { e } " )
143+
144+ return stored_files
145+
146+ @group ("StaticResolver" )
78147 def create_packages_and_dependencies (self ):
79148 """
80149 Create the statically resolved packages and their dependencies
0 commit comments