Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
harababurel committed Dec 12, 2018
1 parent 43143e0 commit 753ab88
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
11 changes: 7 additions & 4 deletions src/gcsf/drive_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct PendingWrite {
}

lazy_static! {
static ref MIME_TYPES: HashMap<&'static str, &'static str> = hashmap!{
static ref MIME_TYPES: HashMap<&'static str, &'static str> = hashmap! {
"application/vnd.google-apps.document" => "application/vnd.oasis.opendocument.text",
"application/vnd.google-apps.presentation" => "application/vnd.oasis.opendocument.presentation",
"application/vnd.google-apps.spreadsheet" => "application/vnd.oasis.opendocument.spreadsheet",
Expand Down Expand Up @@ -236,10 +236,12 @@ impl DriveFacade {
.next()
.ok_or(err_msg(
"No files on drive. Can't deduce drive id for 'My Drive'",
))?.parents
))?
.parents
.ok_or(err_msg(
"Probed file has no parents. Can't deduce drive id for 'My Drive'",
))?.into_iter()
))?
.into_iter()
.take(1)
.next()
.ok_or(err_msg(
Expand All @@ -262,7 +264,8 @@ impl DriveFacade {
result.1.start_page_token.unwrap_or(
err_msg(
"Received OK response from drive but there is no startPageToken included.",
).to_string(),
)
.to_string(),
)
})
}
Expand Down
8 changes: 5 additions & 3 deletions src/gcsf/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum FileId {
}

lazy_static! {
static ref EXTENSIONS: HashMap<&'static str, &'static str> = hashmap!{
static ref EXTENSIONS: HashMap<&'static str, &'static str> = hashmap! {
"application/vnd.google-apps.document" => "#.odt",
"application/vnd.google-apps.presentation" => "#.odp",
"application/vnd.google-apps.spreadsheet" => "#.ods",
Expand Down Expand Up @@ -69,7 +69,8 @@ impl File {
&drive_file.created_time,
&drive_file.modified_time,
&drive_file.viewed_by_me_time,
].iter()
]
.iter()
.map(
|time| match DateTime::parse_from_rfc3339(time.as_ref().unwrap_or(&String::new())) {
Ok(t) => Timespec {
Expand All @@ -78,7 +79,8 @@ impl File {
},
Err(_) => Timespec { sec: 0, nsec: 0 },
},
).collect();
)
.collect();

let (crtime, mtime, atime) = (times[0], times[1], times[2]);
let bsize = 512;
Expand Down
3 changes: 2 additions & 1 deletion src/gcsf/file_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ impl FileManager {
.get_children(&id)
.ok_or(err_msg(
"FileManager::add_file_locally() could not get file siblings",
))?.iter()
))?
.iter()
.filter(|child| child.name == file.name)
.count();

Expand Down
17 changes: 10 additions & 7 deletions src/gcsf/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ impl Filesystem for GCSF {
let id = f.drive_id().unwrap();

(mime, id)
}).unwrap();
})
.unwrap();

reply.data(
self.manager
Expand Down Expand Up @@ -287,9 +288,10 @@ impl Filesystem for GCSF {
drive_file: Some(drive3::File {
name: Some(filename.clone()),
mime_type: None,
parents: Some(vec![
self.manager.get_drive_id(&FileId::Inode(parent)).unwrap(),
]),
parents: Some(vec![self
.manager
.get_drive_id(&FileId::Inode(parent))
.unwrap()]),
..Default::default()
}),
};
Expand Down Expand Up @@ -384,9 +386,10 @@ impl Filesystem for GCSF {
drive_file: Some(drive3::File {
name: Some(dirname.clone()),
mime_type: Some("application/vnd.google-apps.folder".to_string()),
parents: Some(vec![
self.manager.get_drive_id(&FileId::Inode(parent)).unwrap(),
]),
parents: Some(vec![self
.manager
.get_drive_id(&FileId::Inode(parent))
.unwrap()]),
..Default::default()
}),
};
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ fn mount_gcsf(config: Config, mountpoint: &str) {
ctrlc::set_handler(move || {
info!("Ctrl-C detected");
r.store(false, Ordering::SeqCst);
}).expect("Error setting Ctrl-C handler");
})
.expect("Error setting Ctrl-C handler");

while running.load(Ordering::SeqCst) {
thread::sleep(time::Duration::from_millis(50));
Expand Down

0 comments on commit 753ab88

Please sign in to comment.