mirror of
https://github.com/etesync/android
synced 2025-03-25 11:55:43 +00:00
Journalmanager: Change getUuid to getUid (the rest says uid too).
This commit is contained in:
parent
7cefb64db2
commit
14e6f757c5
@ -69,7 +69,7 @@ abstract class BaseManager {
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
private String uid;
|
||||
|
||||
public String getUuid() {
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ public class JournalEntryManager extends BaseManager {
|
||||
|
||||
void verify(Crypto.CryptoManager crypto, Entry previous) throws Exceptions.IntegrityException {
|
||||
String correctHash = calculateHmac(crypto, previous);
|
||||
if (!getUuid().equals(correctHash)) {
|
||||
throw new Exceptions.IntegrityException("Bad HMAC. " + getUuid() + " != " + correctHash);
|
||||
if (!getUid().equals(correctHash)) {
|
||||
throw new Exceptions.IntegrityException("Bad HMAC. " + getUid() + " != " + correctHash);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class JournalEntryManager extends BaseManager {
|
||||
private String calculateHmac(Crypto.CryptoManager crypto, Entry previous) {
|
||||
String uuid = null;
|
||||
if (previous != null) {
|
||||
uuid = previous.getUuid();
|
||||
uuid = previous.getUid();
|
||||
}
|
||||
|
||||
return Crypto.toHex(calculateHmac(crypto, uuid));
|
||||
|
@ -12,7 +12,6 @@ import com.etesync.syncadapter.App;
|
||||
import com.etesync.syncadapter.GsonHelper;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
@ -49,7 +48,7 @@ public class JournalManager extends BaseManager {
|
||||
List<Journal> ret = GsonHelper.gson.fromJson(body.charStream(), journalType);
|
||||
|
||||
for (Journal journal : ret) {
|
||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), keyBase64, journal.getUuid());
|
||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), keyBase64, journal.getUid());
|
||||
journal.processFromJson();
|
||||
journal.verify(crypto);
|
||||
}
|
||||
@ -58,7 +57,7 @@ public class JournalManager extends BaseManager {
|
||||
}
|
||||
|
||||
public void deleteJournal(Journal journal) throws Exceptions.HttpException {
|
||||
HttpUrl remote = this.remote.resolve(journal.getUuid() + "/");
|
||||
HttpUrl remote = this.remote.resolve(journal.getUid() + "/");
|
||||
Request request = new Request.Builder()
|
||||
.delete()
|
||||
.url(remote)
|
||||
@ -79,7 +78,7 @@ public class JournalManager extends BaseManager {
|
||||
}
|
||||
|
||||
public void updateJournal(Journal journal) throws Exceptions.HttpException {
|
||||
HttpUrl remote = this.remote.resolve(journal.getUuid() + "/");
|
||||
HttpUrl remote = this.remote.resolve(journal.getUid() + "/");
|
||||
RequestBody body = RequestBody.create(JSON, journal.toJson());
|
||||
|
||||
Request request = new Request.Builder()
|
||||
@ -125,7 +124,7 @@ public class JournalManager extends BaseManager {
|
||||
}
|
||||
|
||||
byte[] calculateHmac(Crypto.CryptoManager crypto) {
|
||||
return super.calculateHmac(crypto, getUuid());
|
||||
return super.calculateHmac(crypto, getUid());
|
||||
}
|
||||
|
||||
public static String genUid() {
|
||||
|
@ -69,7 +69,7 @@ public class CollectionInfo implements Serializable {
|
||||
}
|
||||
|
||||
public void updateFromJournal(JournalManager.Journal journal) {
|
||||
uid = journal.getUuid();
|
||||
uid = journal.getUid();
|
||||
version = journal.getVersion();
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public abstract class SyncAdapterService extends Service {
|
||||
List<CollectionInfo> collections = new LinkedList<>();
|
||||
|
||||
for (JournalManager.Journal journal : journalsManager.getJournals(settings.password())) {
|
||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), settings.password(), journal.getUuid());
|
||||
Crypto.CryptoManager crypto = new Crypto.CryptoManager(journal.getVersion(), settings.password(), journal.getUid());
|
||||
CollectionInfo info = CollectionInfo.fromJson(journal.getContent(crypto));
|
||||
info.updateFromJournal(journal);
|
||||
|
||||
|
@ -256,7 +256,7 @@ abstract public class SyncManager {
|
||||
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
||||
|
||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
||||
persistSyncEntry(entry.getUuid(), cEntry);
|
||||
persistSyncEntry(entry.getUid(), cEntry);
|
||||
if (cEntry.isAction(SyncEntry.Actions.DELETE)) {
|
||||
continue;
|
||||
}
|
||||
@ -276,9 +276,9 @@ abstract public class SyncManager {
|
||||
int i = 0;
|
||||
for (JournalEntryManager.Entry entry : remoteEntries) {
|
||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(crypto, entry);
|
||||
persistSyncEntry(entry.getUuid(), cEntry);
|
||||
persistSyncEntry(entry.getUid(), cEntry);
|
||||
i++;
|
||||
if (remoteCTag.equals(entry.getUuid())) {
|
||||
if (remoteCTag.equals(entry.getUid())) {
|
||||
remoteEntries.subList(0, i).clear();
|
||||
break;
|
||||
}
|
||||
@ -307,9 +307,9 @@ abstract public class SyncManager {
|
||||
App.log.info("Processing resource for journal entry");
|
||||
processSyncEntry(cEntry);
|
||||
|
||||
persistSyncEntry(entry.getUuid(), cEntry);
|
||||
persistSyncEntry(entry.getUid(), cEntry);
|
||||
|
||||
remoteCTag = entry.getUuid();
|
||||
remoteCTag = entry.getUid();
|
||||
}
|
||||
} finally {
|
||||
saveSyncTag();
|
||||
@ -325,7 +325,7 @@ abstract public class SyncManager {
|
||||
if (!localEntries.isEmpty()) {
|
||||
for (List<JournalEntryManager.Entry> entries : ListUtils.partition(localEntries, MAX_PUSH)) {
|
||||
journal.putEntries(entries, remoteCTag);
|
||||
remoteCTag = entries.get(entries.size() - 1).getUuid();
|
||||
remoteCTag = entries.get(entries.size() - 1).getUid();
|
||||
pushed += entries.size();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user