Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
jio
Commits
7cd55e13
Commit
7cd55e13
authored
Nov 17, 2016
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReplicateStorage: Code improvment
parent
829a447c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
43 deletions
+36
-43
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+36
-43
No files found.
src/jio.storage/replicatestorage.js
View file @
7cd55e13
...
...
@@ -213,7 +213,7 @@
// Do not sync the signature document
skip_document_dict
[
context
.
_signature_hash
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
function
allAttachmentMethod
(
storage
,
id
)
{
...
...
@@ -232,7 +232,7 @@
&&
skip_document_dict
[
id
].
skip
===
true
;
}
return
skip_document_dict
[
id
]
!==
undefined
&&
(
skip_document_dict
[
id
].
skip_attachment
s
===
true
&&
(
skip_document_dict
[
id
].
skip_attachment
_list
===
true
||
(
skip_document_dict
[
id
].
attachments
!==
undefined
&&
skip_document_dict
[
id
].
attachments
[
attachment_id
]
===
true
));
}
...
...
@@ -241,7 +241,7 @@
if
(
skip_document_dict
[
id
]
===
undefined
)
{
skip_document_dict
[
id
]
=
{
skip
:
false
,
skip_attachment
s
:
false
,
skip_attachment
_list
:
false
,
attachments
:
{}
};
}
...
...
@@ -276,9 +276,9 @@
return
jIO
.
util
.
readBlobAsArrayBuffer
(
attachment_blob
);
})
.
push
(
function
(
evt
)
{
return
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
})
.
push
(
function
(
remote_hash
)
{
var
remote_hash
=
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
if
(
remote_hash
===
status_hash
)
{
// No modification. Attachment can be removed.
return
destination
.
removeAttachment
(
id
,
attachment_id
)
...
...
@@ -351,12 +351,10 @@
return
jIO
.
util
.
readBlobAsArrayBuffer
(
attachment_blob
);
})
.
push
(
function
(
evt
)
{
return
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
})
.
push
(
function
(
hash
)
{
hash_document
.
attachments_hash
[
attachment_id
]
=
hash
;
hash_document
.
attachments_hash
[
attachment_id
]
=
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
hash_document
.
updated
=
true
;
return
;
});
...
...
@@ -379,11 +377,11 @@
});
}
function
copyDocumentAndAttachment
s
(
source
,
destination
,
source_id
,
destination_id
,
doc
,
hash_document
,
garbage_collect
)
{
function
copyDocumentAndAttachment
List
(
source
,
destination
,
source_id
,
destination_id
,
doc
,
hash_document
,
garbage_collect
)
{
if
(
garbage_collect
===
undefined
)
{
garbage_collect
=
false
;
}
...
...
@@ -422,7 +420,7 @@
if
(
source_id
===
destination_id
)
{
skip_document_dict
[
destination_id
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
}
if
(
garbage_collect
===
true
)
{
...
...
@@ -435,7 +433,7 @@
delete
signature_dict
[
source_id
];
skip_document_dict
[
source_id
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
return
context
.
_signature_sub_storage
.
remove
(
source_id
);
}
...
...
@@ -460,17 +458,17 @@
};
post_id
=
new_id
;
signature_dict
[
post_id
]
=
hash_document
;
return
copyDocumentAndAttachment
s
(
source
,
source
,
id
,
post_id
,
doc
,
hash_document
,
true
);
return
copyDocumentAndAttachment
List
(
source
,
source
,
id
,
post_id
,
doc
,
hash_document
,
true
);
})
.
push
(
function
()
{
return
copyDocumentAndAttachment
s
(
source
,
destination
,
post_id
,
post_id
,
doc
,
signature_dict
[
post_id
]);
return
copyDocumentAndAttachment
List
(
source
,
destination
,
post_id
,
post_id
,
doc
,
signature_dict
[
post_id
]);
})
.
push
(
function
()
{
return
post_id
;
...
...
@@ -567,7 +565,7 @@
.
push
(
function
()
{
skip_document_dict
[
id
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
return
;
});
...
...
@@ -597,7 +595,7 @@
signature_dict
[
id
].
updated
=
true
;
skip_document_dict
[
id
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
return
;
});
...
...
@@ -610,7 +608,7 @@
.
push
(
function
()
{
skip_document_dict
[
id
]
=
{
skip
:
true
,
skip_attachment
s
:
true
skip_attachment
_list
:
true
};
delete
signature_dict
[
id
];
return
;
...
...
@@ -647,16 +645,11 @@
.
push
(
function
(
result
)
{
attachment_blob
=
result
;
// Calculate Attachment Hash
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsArrayBuffer
(
attachment_blob
);
})
.
push
(
function
(
evt
)
{
return
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
});
return
jIO
.
util
.
readBlobAsArrayBuffer
(
attachment_blob
);
})
.
push
(
function
(
local_hash
)
{
var
status_hash
=
attachment_signature_dict
[
attachment_id
];
.
push
(
function
(
evt
)
{
var
status_hash
=
attachment_signature_dict
[
attachment_id
],
local_hash
=
generateHashFromArrayBuffer
(
evt
.
target
.
result
);
if
(
local_hash
!==
status_hash
)
{
// Local modification
return
destination
.
getAttachment
(
id
,
attachment_id
,
...
...
@@ -708,7 +701,7 @@
// attachment to a non-existent attachment.
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
return
copyDocumentAndAttachment
s
(
return
copyDocumentAndAttachment
List
(
source
,
destination
,
id
,
...
...
@@ -748,7 +741,7 @@
var
hash_document
;
if
(
skip_document_dict
[
id
]
!==
undefined
&&
skip_document_dict
[
id
].
skip
===
true
&&
skip_document_dict
[
id
].
skip_attachment
s
===
true
)
{
&&
skip_document_dict
[
id
].
skip_attachment
_list
===
true
)
{
return
;
}
queue
...
...
@@ -834,7 +827,7 @@
id
=
current_id
;
hash_document
=
signature_dict
[
id
];
if
(
skip_document_dict
[
id
]
!==
undefined
&&
skip_document_dict
.
skip_attachment
s
===
true
)
{
&&
skip_document_dict
.
skip_attachment
_list
===
true
)
{
// No attachments to check
return
{};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment