Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure ReentrantLock is unlocked after being locked, and on same thread #2759

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,16 @@ public static boolean isExternalStorageReadable() {
@UiThread
public static void initializeFileDirsPaths(Context context) {
ThreadUtils.checkThread(TAG);
lockPathLoaders();
if (resourcesCachePath == null || internalCachePath == null) {
new FileDirsPathsTask().execute(context);
}
new FileDirsPathsTask().execute(context);
}

private static class FileDirsPathsTask extends AsyncTask<Context, Void, String[]> {

@Override
protected void onCancelled() {
unlockPathLoaders();
}

@NonNull
@Override
protected String[] doInBackground(Context... contexts) {
return new String[] {
getCachePath(contexts[0]),
contexts[0].getCacheDir().getAbsolutePath()
};
}
private static class FileDirsPathsTask extends AsyncTask<Context, Void, Void> {

@Override
protected void onPostExecute(String[] paths) {
resourcesCachePath = paths[0];
internalCachePath = paths[1];
unlockPathLoaders();
protected Void doInBackground(Context... contexts) {
getResourcesCachePath(contexts[0]);
getInternalCachePath(contexts[0]);
return null;
}
}

Expand Down Expand Up @@ -358,16 +341,6 @@ private static boolean isPathWritable(String path) {
return new File(path).canWrite();
}

private static void lockPathLoaders() {
internalCachePathLoaderLock.lock();
resourcesCachePathLoaderLock.lock();
}

private static void unlockPathLoaders() {
resourcesCachePathLoaderLock.unlock();
internalCachePathLoaderLock.unlock();
}

louwers marked this conversation as resolved.
Show resolved Hide resolved
@Keep
private long nativePtr;

Expand Down
Loading