Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2017-11-02 15:24:42 +0300
committerLluis Sanchez <lluis@xamarin.com>2017-11-02 16:42:23 +0300
commit3147dc5c2a2a147e95745a87d1a9d927f4fbf08d (patch)
tree18bb05e190876412dd957f172f55a71a644a0130 /Mono.Addins/Mono.Addins.Database/AddinScanner.cs
parent5d6bfc227b8e9feee162be05788f50e823cdba4f (diff)
Adds support for generating add-in data cache files
Added a new command and api that can be used to generate a file next to each add-in file that contains the result of the scan. The next time the add-in needs to be scanned, the scanner will load the data from the data file instead of scanning again the add-in.
Diffstat (limited to 'Mono.Addins/Mono.Addins.Database/AddinScanner.cs')
-rw-r--r--Mono.Addins/Mono.Addins.Database/AddinScanner.cs51
1 files changed, 36 insertions, 15 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
index 80e0e7d..480d2bb 100644
--- a/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
+++ b/Mono.Addins/Mono.Addins.Database/AddinScanner.cs
@@ -229,30 +229,51 @@ namespace Mono.Addins.Database
return;
}
+ string scannedAddinId = null;
+ bool scannedIsRoot = false;
+ bool scanSuccessful = false;
+ bool loadedFromCacheFile = false;
+ AddinDescription config = null;
+
string ext = Path.GetExtension (file).ToLower ();
- if ((ext == ".dll" || ext == ".exe") && !Util.IsManagedAssembly (file)) {
- // Ignore dlls and exes which are not managed assemblies
- folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true);
- return;
+
+ var cachedDataFile = Path.Combine (file, ".addindata");
+ if (File.Exists (cachedDataFile)) {
+ if (database.ReadAddinDescription (monitor, cachedDataFile, out config)) {
+ scanSuccessful = true;
+ loadedFromCacheFile = true;
+ if (monitor.LogLevel > 1)
+ monitor.Log ("Loading cached add-in data file: " + file);
+ } else if (monitor.LogLevel > 1)
+ monitor.Log ("Cached add-in data file could not be loaded, ignoring: " + file);
}
+ if (!loadedFromCacheFile) {
+ if ((ext == ".dll" || ext == ".exe") && !Util.IsManagedAssembly (file)) {
+ // Ignore dlls and exes which are not managed assemblies
+ folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true);
+ return;
+ }
- if (monitor.LogLevel > 1)
- monitor.Log ("Scanning file: " + file);
+ if (monitor.LogLevel > 1)
+ monitor.Log ("Scanning file: " + file);
+ }
// Log the file to be scanned, so in case of a process crash the main process
// will know what crashed
monitor.Log ("plog:scan:" + file);
- string scannedAddinId = null;
- bool scannedIsRoot = false;
- bool scanSuccessful = false;
- AddinDescription config = null;
-
try {
- if (ext == ".dll" || ext == ".exe")
- scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
- else
- scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);
+ if (!loadedFromCacheFile) {
+ if (ext == ".dll" || ext == ".exe")
+ scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
+ else
+ scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);
+
+ if (scanSuccessful && scanResult.ShouldGenerateAddinCacheDataFile (file)) {
+ // Save a binary data file next to the scanned file
+ database.SaveDescription (monitor, config, cachedDataFile);
+ }
+ }
if (config != null) {