Browse Source

Removed dbg

master
Julio Biason 4 years ago
parent
commit
689f86d0f8
  1. 1450
      Cargo.lock
  2. 2
      Cargo.toml
  3. 14
      src/main.rs
  4. 4
      src/storage/attachment.rs
  5. 4
      src/storage/data.rs
  6. 16
      src/storage/joplin.rs

1450
Cargo.lock generated

File diff suppressed because it is too large Load Diff

2
Cargo.toml

@ -11,3 +11,5 @@ reqwest = "0.9"
serde = "*"
serde_derive = "*"
toml = "0.5"
log = "0.4"
env_logger = "0.8"

14
src/main.rs

@ -30,6 +30,8 @@ mod config;
mod storage;
fn main() {
env_logger::init();
let config = match config::Config::get() {
Ok(config) => config,
Err(_) => {
@ -38,7 +40,8 @@ fn main() {
}
};
let top = dbg!(config.favourite.last.to_string());
let top = config.favourite.last.to_string();
log::debug!("Last favourite seen: {}", top);
let storage: Box<dyn Storage> = match &config.joplin {
Some(joplin) => Box::new(Joplin::new_from_config(&joplin)),
None => Box::new(Filesystem::new()),
@ -49,9 +52,14 @@ fn main() {
.favourites()
.unwrap()
.items_iter()
.take_while(|record| dbg!(record).id != top)
.take_while(|record| {
println!("Current ID: {} (last favourite: {})", record.id, top);
record.id != top
})
.map(|record| {
let conversion = dbg!(Data::from(dbg!(&record)));
log::debug!("Incoming record: {:?}", record);
let conversion = Data::from(&record);
log::debug!("Converted record: {:?}", conversion);
storage.save(&conversion);
record
})

4
src/storage/attachment.rs

@ -40,10 +40,10 @@ impl Attachment {
let mut frags = self.url.rsplitn(2, '/');
if let Some(path_part) = frags.next() {
dbg!(path_part.split('?').next().unwrap_or(&self.url).to_string())
path_part.split('?').next().unwrap_or(&self.url).to_string()
} else {
// this is, most of the time, bad (due special characters -- like '?' -- and path)
dbg!(self.url.to_string())
self.url.to_string()
}
}

4
src/storage/data.rs

@ -36,12 +36,10 @@ pub struct Data {
/// Convert the incoming Status from Elefren to ours.
impl From<&Status> for Data {
fn from(origin: &Status) -> Self {
println!("Downloading ID: {}", origin.id);
Self {
id: origin.id.to_string(),
account: origin.account.acct.to_string(),
text: dbg!(build_text(origin)),
text: build_text(origin),
attachments: origin
.media_attachments
.iter()

16
src/storage/joplin.rs

@ -64,11 +64,12 @@ pub struct Joplin {
impl Storage for Joplin {
fn save(&self, record: &Data) {
let resources = dbg!(self.save_attachments(&record));
let resources = self.save_attachments(&record);
log::debug!("Record attachments: {:?}", resources);
let mut text = record.text.to_string();
let title = format!("{}/{}", record.account, record.id);
Joplin::add_resources_to_text(&mut text, &resources);
dbg!(self.save_content(&title, &text, &record.source));
self.save_content(&title, &text, &record.source);
}
}
@ -82,14 +83,13 @@ impl Joplin {
client: reqwest::Client::new(),
},
None => {
println!("The notebook {} does not exist", &config.folder);
panic!("The specified notebook does not exist");
}
}
}
fn find_folder(config: &JoplinConfig) -> Option<String> {
match dbg!(Joplin::get_folder_list(config)) {
match Joplin::get_folder_list(config) {
Ok(folders) => {
for folder in folders {
if folder.title == *config.folder {
@ -99,7 +99,6 @@ impl Joplin {
None
}
Err(_) => {
println!("Failed to retrieve the notebook list");
panic!("Failed to retrieve Joplin notebook list");
}
}
@ -111,12 +110,12 @@ impl Joplin {
let mut folders: Vec<Folder> = Vec::new();
while has_more {
let base_url = dbg!(format!(
let base_url = format!(
"http://localhost:{port}/folders?token={token}&page={page}",
port = config.port,
token = config.token,
page = page
));
);
let folder_list: FolderList = reqwest::get(&base_url)?.json()?;
folder_list.items.iter().for_each(|folder| {
@ -168,8 +167,7 @@ impl Joplin {
.map(|attachment| {
let mut buffer: Vec<u8> = vec![];
attachment.download().copy_to(&mut buffer).unwrap();
let resource_id =
dbg!(self.upload_resource(attachment.filename().to_string(), buffer));
let resource_id = self.upload_resource(attachment.filename().to_string(), buffer);
Resource {
id: resource_id,

Loading…
Cancel
Save