Fix synchronisation problem between client and server
... for actions pin, unpin and setNote
This commit is contained in:
parent
217b56b88c
commit
d20680f228
|
@ -678,8 +678,7 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
|
||||
@Override
|
||||
public void setNote(Recording rec, String note) throws IOException {
|
||||
rec.setNote(note);
|
||||
recordingManager.saveRecording(rec);
|
||||
recordingManager.setNote(rec, note);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.time.Duration;
|
|||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -217,8 +219,9 @@ public class RecordingManager {
|
|||
public void pin(Recording recording) throws IOException {
|
||||
recordingsLock.lock();
|
||||
try {
|
||||
recording.setPinned(true);
|
||||
saveRecording(recording);
|
||||
Recording local = getRecording(recording);
|
||||
local.setPinned(true);
|
||||
saveRecording(local);
|
||||
} finally {
|
||||
recordingsLock.unlock();
|
||||
}
|
||||
|
@ -227,10 +230,31 @@ public class RecordingManager {
|
|||
public void unpin(Recording recording) throws IOException {
|
||||
recordingsLock.lock();
|
||||
try {
|
||||
recording.setPinned(false);
|
||||
saveRecording(recording);
|
||||
Recording local = getRecording(recording);
|
||||
local.setPinned(false);
|
||||
saveRecording(local);
|
||||
} finally {
|
||||
recordingsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setNote(Recording rec, String note) throws IOException {
|
||||
recordingsLock.lock();
|
||||
try {
|
||||
Recording local = getRecording(rec);
|
||||
local.setNote(note);
|
||||
saveRecording(local);
|
||||
} finally {
|
||||
recordingsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private Recording getRecording(Recording rec) {
|
||||
for (Recording r : getAll()) {
|
||||
if(Objects.equals(r, rec)) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("Recording not found");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue