mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-27 06:41:15 +00:00
Fix device completion for v0.14.6 (fixes #736)
This commit is contained in:
parent
b4e08a472a
commit
ebc0fe88de
1 changed files with 7 additions and 1 deletions
|
@ -157,6 +157,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
public long inSyncFiles;
|
public long inSyncFiles;
|
||||||
public long needBytes;
|
public long needBytes;
|
||||||
public long needFiles;
|
public long needFiles;
|
||||||
|
public long needDeletes;
|
||||||
public String state;
|
public String state;
|
||||||
public String invalid;
|
public String invalid;
|
||||||
}
|
}
|
||||||
|
@ -666,6 +667,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
private int getDeviceCompletion(String deviceId) {
|
private int getDeviceCompletion(String deviceId) {
|
||||||
int folderCount = 0;
|
int folderCount = 0;
|
||||||
float percentageSum = 0;
|
float percentageSum = 0;
|
||||||
|
// Syncthing UI limits pending deletes to 95% completion of a device
|
||||||
|
int maxPercentage = 100;
|
||||||
for (Map.Entry<String, Model> modelInfo : mCachedModelInfo.entrySet()) {
|
for (Map.Entry<String, Model> modelInfo : mCachedModelInfo.entrySet()) {
|
||||||
boolean isShared = false;
|
boolean isShared = false;
|
||||||
outerloop:
|
outerloop:
|
||||||
|
@ -681,6 +684,8 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
if (isShared) {
|
if (isShared) {
|
||||||
long global = modelInfo.getValue().globalBytes;
|
long global = modelInfo.getValue().globalBytes;
|
||||||
long local = modelInfo.getValue().inSyncBytes;
|
long local = modelInfo.getValue().inSyncBytes;
|
||||||
|
if (modelInfo.getValue().needFiles == 0 && modelInfo.getValue().needDeletes > 0)
|
||||||
|
maxPercentage = 95;
|
||||||
percentageSum += (global != 0)
|
percentageSum += (global != 0)
|
||||||
? (local * 100f) / global
|
? (local * 100f) / global
|
||||||
: 100f;
|
: 100f;
|
||||||
|
@ -688,7 +693,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (folderCount != 0)
|
return (folderCount != 0)
|
||||||
? Math.round(percentageSum / folderCount)
|
? Math.min(Math.round(percentageSum / folderCount), maxPercentage)
|
||||||
: 100;
|
: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,6 +749,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
m.inSyncFiles = json.getLong("inSyncFiles");
|
m.inSyncFiles = json.getLong("inSyncFiles");
|
||||||
m.needBytes = json.getLong("needBytes");
|
m.needBytes = json.getLong("needBytes");
|
||||||
m.needFiles = json.getLong("needFiles");
|
m.needFiles = json.getLong("needFiles");
|
||||||
|
m.needDeletes = json.getLong("needDeletes");
|
||||||
m.state = json.getString("state");
|
m.state = json.getString("state");
|
||||||
m.invalid = json.optString("invalid");
|
m.invalid = json.optString("invalid");
|
||||||
mCachedModelInfo.put(folderId, m);
|
mCachedModelInfo.put(folderId, m);
|
||||||
|
|
Loading…
Reference in a new issue