Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
feat(files): improve fail message and insert files on database
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <rhernandez@teclib.com>
  • Loading branch information
rafaelje authored and Hector Rondon committed Apr 11, 2018
1 parent 3527163 commit cc01dca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/org/flyve/mdm/agent/services/PoliciesFiles.java
Expand Up @@ -36,6 +36,7 @@

import org.flyve.mdm.agent.R;
import org.flyve.mdm.agent.core.Routes;
import org.flyve.mdm.agent.room.database.AppDataBase;
import org.flyve.mdm.agent.utils.ConnectionHTTP;
import org.flyve.mdm.agent.utils.FlyveLog;
import org.flyve.mdm.agent.utils.Helpers;
Expand Down Expand Up @@ -255,9 +256,18 @@ private String getFile(JSONObject jsonObjDownload, String path, String url, Stri
publishProgress(100);
FlyveLog.d("Download ready");

org.flyve.mdm.agent.room.entity.File dataFile = new org.flyve.mdm.agent.room.entity.File();
dataFile.fileName = fileName;
dataFile.filePath = file.getAbsolutePath();

AppDataBase dataBase = AppDataBase.getAppDatabase(context);
dataBase.FileDao().deleteByName(fileName);
dataBase.FileDao().insert(dataFile);

return file.getAbsolutePath();
} else {
publishProgress(100);
mBuilder.setContentText("Download " + fileName + " Fail");
FlyveLog.e("Download fail: " + data);

return "";
Expand Down

0 comments on commit cc01dca

Please sign in to comment.