Changeset 7231
- Timestamp:
- Nov 16, 2016, 12:57:05 PM (6 years ago)
- Location:
- trunk/src/core/net/sf/basedb/util/extensions/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java
r6898 r7231 35 35 import java.util.Set; 36 36 import java.util.TreeMap; 37 import java.util.TreeSet; 37 38 38 39 import net.sf.basedb.core.ItemAlreadyExistsException; … … 76 77 private int numUnmodified; 77 78 private int numDeleted; 79 private int numIgnored; 78 80 79 81 /** … … 88 90 this.registry = registry; 89 91 this.settings = new Settings(this, settingsFile); 90 this.ignore = new HashSet<File>();92 this.ignore = new TreeSet<File>(settings.getIgnoredFiles()); 91 93 this.directories = new HashSet<File>(); 92 94 this.xtFiles = new TreeMap<URI, ExtensionsFile>(new JarFirstURIComparator()); … … 141 143 { 142 144 if (file == null) return; 143 ignore.add(file); 145 if (ignore.add(file)) 146 { 147 settings.setIgnoredFile(file, true); 148 removeFile(file); 149 } 144 150 } 145 151 … … 152 158 { 153 159 if (file == null) return; 154 ignore.remove(file); 155 } 156 160 if (ignore.remove(file)) 161 { 162 settings.setIgnoredFile(file, false); 163 } 164 } 165 166 /** 167 Get all ignored files. 168 169 @param onlyInManagedDirectory TRUE to only look for files that 170 are located in a managed directory 171 @since 3.10 172 */ 173 public List<File> getIgnoredFiles(boolean onlyInManagedDirectory) 174 { 175 // Create a copy, or the iterator will fail if new 176 // files are added by another thread 177 List<File> copy = new ArrayList<File>(ignore.size()); 178 if (onlyInManagedDirectory) 179 { 180 for (File f : ignore) 181 { 182 if (directories.contains(f.getParentFile())) copy.add(f); 183 } 184 } 185 else 186 { 187 copy.addAll(ignore); 188 } 189 return copy; 190 } 191 157 192 /** 158 193 Add a directory to this manager. The directory will be monitored … … 190 225 ExtensionsFile xtFile = new ExtensionsFile(this, file); 191 226 addExtensionsFile(xtFile); 227 ignore.remove(file); 192 228 return xtFile; 193 229 } … … 260 296 numDeleted = 0; 261 297 numUnmodified = 0; 298 numIgnored = 0; 262 299 263 300 // 1. Check and count all known files … … 337 374 338 375 /** 376 Get the number of ignored files that was found in the last 377 call to {@link #scanForChanges()}. 378 @since 3.10 379 */ 380 public int getNumIgnored() 381 { 382 return numIgnored; 383 } 384 385 /** 339 386 Scan the given directory and add files that are new. 340 387 @param dir The directory to scan … … 363 410 { 364 411 log.debug("File '" + file + "' is ignored."); 412 numIgnored++; 365 413 continue; // with the next file 366 414 } … … 417 465 { 418 466 log.debug("File '" + file + "' is ignored."); 467 numIgnored++; 419 468 continue; // with the next file 420 469 } -
trunk/src/core/net/sf/basedb/util/extensions/manager/Settings.java
r6875 r7231 74 74 private Preset settings; 75 75 private Preset installedFiles; 76 private Preset ignoredFiles; 76 77 private Preset disabledExtensions; 77 78 private Preset disabledExtensionPoints; … … 104 105 this.settings = presets.getDefault(); 105 106 this.installedFiles = presets.getPreset("installed-files"); 107 this.ignoredFiles = presets.getPreset("ignored-files"); 106 108 this.disabledExtensionPoints = presets.getPreset("disabled-extension-points"); 107 109 this.disabledExtensions = presets.getPreset("disabled-extensions"); … … 245 247 246 248 /** 249 Check if the given file is marked as ignored. 250 @since 3.10 251 */ 252 public boolean isIgnoredFile(File file) 253 { 254 return Values.getBoolean(ignoredFiles.getSetting(file.getAbsolutePath())); 255 } 256 257 /** 258 Mark the given file as ignored/not ignored by the extension system. 259 @since 3.10 260 */ 261 public void setIgnoredFile(File file, boolean ignore) 262 { 263 if (file == null) return; 264 hasChanged = true; 265 ignoredFiles.setSetting(file.getAbsolutePath(), ignore ? "1" : null); 266 } 267 268 /** 269 Get a list with all files that are ignored. 270 @since 3.10 271 */ 272 public List<File> getIgnoredFiles() 273 { 274 List<String> paths = ignoredFiles.getKeys(); 275 List<File> files = new ArrayList<File>(paths.size()); 276 for (String path : paths) 277 { 278 files.add(new File(path)); 279 } 280 return files; 281 } 282 283 /** 247 284 Save the settings to disk. If the settings has not been 248 285 changed the file is not written.
Note: See TracChangeset
for help on using the changeset viewer.