小编Les*_*zek的帖子

Firebase存储 - StorageReference.getFile()在设备脱机时崩溃

当我尝试使用方法从Firebase Storage下载文件时,StorageReference.getFile(File)它会在设备脱机并达到超时时崩溃.Logcat在DynamicModulesC中显示NPE:

java.lang.NullPointerException: null reference
at asn.a(:com.google.android.gms.DynamiteModulesC:27)                                                                                     
Run Code Online (Sandbox Code Playgroud)

相同的代码正常工作,并在互联网连接可用时下载文件.我已经在Android 4.1和6.0的设备和模拟器上进行了测试.Firebase SDK版本9.6.1.这是firebase SDK中的错误吗?我错过了什么?

代码简单:

FirebaseStorage firebaseStorage = FirebaseStorage.getInstance();
//firebaseStorage.setMaxDownloadRetryTimeMillis(15 * 1000);
StorageReference remoteDir= firebaseStorage.getReference().child("dir-with-files");
File destinationFile= new File("file-in-app-internal-storage");
StorageReference fileRef = remoteDir.child("file-from-firebase");
fileRef.getFile(destinationFile);
Run Code Online (Sandbox Code Playgroud)

完整崩溃日志:

10-02 10:49:57.577 9429-9464/com.github.lecho.mobilization W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86_64
10-02 10:49:57.610 9429-9464/com.github.lecho.mobilization I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:1
10-02 10:49:57.610 9429-9464/com.github.lecho.mobilization I/DynamiteModule: Selected remote version of com.google.android.gms.firebasestorage, version >= 1
10-02 10:49:57.628 9429-9464/com.github.lecho.mobilization W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000002/n/x86_64

10-02 10:50:11.599 9429-9462/com.github.lecho.mobilization W/ExponenentialBackoff: …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-realtime-database firebase-storage

7
推荐指数
1
解决办法
3058
查看次数

使用sql进行递归计算以形成树

我正在研究一个简单的问题,并希望使用SQL来解决它.我有3个表类别,项目和关系表CategoryItem.我需要返回每个类别的项目数,但扭曲是类别按父子关系排列,子类别中的项目数应该添加到其父类别中的计数.请使用SQL考虑下面的示例数据和预期的结果集.

Id  Name    ParentCategoryId
1   Category1   Null
2   Category1.1 1
3   Category2.1 2
4   Category1.2 1
5   Category3.1 3

ID  CateoryId   ItemId
1   5              1
2   4              2
3   5              2
4   3              1
5   2              3
6   1              1
7   3              2
Run Code Online (Sandbox Code Playgroud)

结果:

CategoryNAme     Count
Category1          7
Category1.1        5
Category2.1        4
Category1.2        1
Category3.1        2
Run Code Online (Sandbox Code Playgroud)

我可以在我的业务层中执行此操作,但由于数据大小,性能并非最佳.我希望如果我能在数据层中做到这一点,我将能够大大提高性能.

在此先感谢您的回复

sql t-sql sql-server recursive-query

6
推荐指数
1
解决办法
1205
查看次数

使用pytest时在同一包中导入的ModuleNotFoundError

我的项目结构似乎是正确的。

setup.py
mypackage/
    __init__.py
    __main__.py
    main.py
    script1.py #import script2 
    script2.py
tests/
    test_script2.py
Run Code Online (Sandbox Code Playgroud)

使用script1.py导入文件。script2.py'import script2'

我可以使用以下命令运行代码而不会出现错误:

python mypackage
python mypackage/main.py
Run Code Online (Sandbox Code Playgroud)

不幸的是,当我尝试使用执行测试pytestpython -m pytest出现错误时,没有命名模块script2(以下完整消息)。我以可编辑模式安装了程序包pip install -e .

我可以通过使用包名称为的导入来解决此问题,import mypackage.script2 as script2但随后,所有克隆我的存储库的人都必须在运行pip之前安装包。否则将mypackage找不到错误。

我希望能够在不安装pip的情况下运行此代码,并可以选择单独运行每个脚本文件。
您能建议我替代解决方案吗?

仓库:pytest-imports-demo

来自pytest的错误消息:

(venv) lecho:~/pytest-imports-demo$ pytest
================================================= test session starts ==================================================
platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/lecho/pytest-imports-demo
collected 0 items / 1 errors                                                                                           

======================================================== ERRORS ========================================================
________________________________________ ERROR collecting tests/test_script2.py …
Run Code Online (Sandbox Code Playgroud)

python pytest

6
推荐指数
1
解决办法
112
查看次数