|
|
|
|
|
|
|
|
public static void close(@NonNull final Repository db) { |
|
|
public static void close(@NonNull final Repository db) { |
|
|
if (db.getDirectory() != null) { |
|
|
if (db.getDirectory() != null) { |
|
|
FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); |
|
|
FileKey key = FileKey.exact(db.getDirectory(), db.getFS()); |
|
|
cache.unregisterAndCloseRepository(key, db); |
|
|
|
|
|
|
|
|
cache.unregisterAndCloseRepository(key); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&& (System.currentTimeMillis() - db.closedAt.get() > expireAfter); |
|
|
&& (System.currentTimeMillis() - db.closedAt.get() > expireAfter); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void unregisterAndCloseRepository(final Key location, |
|
|
|
|
|
Repository db) { |
|
|
|
|
|
|
|
|
private void unregisterAndCloseRepository(final Key location) { |
|
|
synchronized (lockFor(location)) { |
|
|
synchronized (lockFor(location)) { |
|
|
Repository oldDb = unregisterRepository(location); |
|
|
Repository oldDb = unregisterRepository(location); |
|
|
if (oldDb != null) { |
|
|
if (oldDb != null) { |