mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #12544 - izgzhen:patch-file-api, r=Manishearth
Patches of File API r? @Manishearth <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12544) <!-- Reviewable:end -->
This commit is contained in:
commit
9c0e7b1cf2
3 changed files with 8 additions and 9 deletions
|
@ -20,6 +20,7 @@ use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId, Relat
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
/// File-based blob
|
/// File-based blob
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
|
@ -183,7 +184,7 @@ impl Blob {
|
||||||
|
|
||||||
match rx.recv().unwrap() {
|
match rx.recv().unwrap() {
|
||||||
Ok(_) => f.id.clone(),
|
Ok(_) => f.id.clone(),
|
||||||
Err(_) => SelectedFileId("".to_string()) // Return a dummy id on error
|
Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()) // Return a dummy id on error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlobImpl::Memory(ref slice) => {
|
BlobImpl::Memory(ref slice) => {
|
||||||
|
@ -194,7 +195,7 @@ impl Blob {
|
||||||
BlobImpl::Sliced(_, _) => {
|
BlobImpl::Sliced(_, _) => {
|
||||||
debug!("Sliced can't have a sliced parent");
|
debug!("Sliced can't have a sliced parent");
|
||||||
// Return dummy id
|
// Return dummy id
|
||||||
SelectedFileId("".to_string())
|
SelectedFileId(Uuid::new_v4().simple().to_string())
|
||||||
}
|
}
|
||||||
BlobImpl::File(ref f) =>
|
BlobImpl::File(ref f) =>
|
||||||
self.create_sliced_url_id(&f.id, rel_pos),
|
self.create_sliced_url_id(&f.id, rel_pos),
|
||||||
|
@ -230,7 +231,7 @@ impl Blob {
|
||||||
match rx.recv().unwrap() {
|
match rx.recv().unwrap() {
|
||||||
Ok(new_id) => SelectedFileId(new_id.0),
|
Ok(new_id) => SelectedFileId(new_id.0),
|
||||||
// Dummy id
|
// Dummy id
|
||||||
Err(_) => SelectedFileId("".to_string()),
|
Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,10 @@ impl File {
|
||||||
let ref typeString = blobPropertyBag.type_;
|
let ref typeString = blobPropertyBag.type_;
|
||||||
|
|
||||||
let modified = filePropertyBag.lastModified;
|
let modified = filePropertyBag.lastModified;
|
||||||
Ok(File::new(global, BlobImpl::new_from_bytes(bytes), filename, modified, typeString))
|
// NOTE: Following behaviour might be removed in future,
|
||||||
|
// see https://github.com/w3c/FileAPI/issues/41
|
||||||
|
let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
|
||||||
|
Ok(File::new(global, BlobImpl::new_from_bytes(bytes), replaced_filename, modified, typeString))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &DOMString {
|
pub fn name(&self) -> &DOMString {
|
||||||
|
|
|
@ -11,8 +11,3 @@
|
||||||
[Various fileBits]
|
[Various fileBits]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
bug: https://github.com/servo/servo/issues/10911
|
bug: https://github.com/servo/servo/issues/10911
|
||||||
|
|
||||||
[Using special character in fileName]
|
|
||||||
expected: FAIL
|
|
||||||
bug: https://github.com/w3c/FileAPI/issues/41
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue