Don't translate placeholder attachment filename in database: Closes #5470.
This commit is contained in:
parent
42f7d8bd41
commit
bbc0da0b39
4 changed files with 14 additions and 14 deletions
|
|
@ -1258,8 +1258,10 @@ public class MessageViewer : WebKit.WebView {
|
||||||
foreach (Geary.Attachment attachment in attachments) {
|
foreach (Geary.Attachment attachment in attachments) {
|
||||||
// Generate the attachment table.
|
// Generate the attachment table.
|
||||||
WebKit.DOM.HTMLElement attachment_table = Util.DOM.clone_node(attachment_template);
|
WebKit.DOM.HTMLElement attachment_table = Util.DOM.clone_node(attachment_template);
|
||||||
|
string filename = Geary.String.is_null_or_whitespace(attachment.filename) ?
|
||||||
|
_("none") : attachment.filename;
|
||||||
Util.DOM.select(attachment_table, ".info .filename")
|
Util.DOM.select(attachment_table, ".info .filename")
|
||||||
.set_inner_text(attachment.filename);
|
.set_inner_text(filename);
|
||||||
Util.DOM.select(attachment_table, ".info .filesize")
|
Util.DOM.select(attachment_table, ".info .filesize")
|
||||||
.set_inner_text(Files.get_filesize_as_string(attachment.filesize));
|
.set_inner_text(Files.get_filesize_as_string(attachment.filesize));
|
||||||
attachment_table.set_attribute("data-attachment-id", "%lld".printf(attachment.id));
|
attachment_table.set_attribute("data-attachment-id", "%lld".printf(attachment.id));
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
public class Geary.Attachment {
|
public class Geary.Attachment {
|
||||||
public const Email.Field REQUIRED_FIELDS = Email.Field.HEADER | Email.Field.BODY;
|
public const Email.Field REQUIRED_FIELDS = Email.Field.HEADER | Email.Field.BODY;
|
||||||
|
|
||||||
public string filename { get; private set; }
|
public string? filename { get; private set; }
|
||||||
public string filepath { get; private set; }
|
public string filepath { get; private set; }
|
||||||
public string mime_type { get; private set; }
|
public string mime_type { get; private set; }
|
||||||
public int64 filesize { get; private set; }
|
public int64 filesize { get; private set; }
|
||||||
public int64 id { get; private set; }
|
public int64 id { get; private set; }
|
||||||
|
|
||||||
internal Attachment(File data_dir, string filename, string mime_type, int64 filesize,
|
internal Attachment(File data_dir, string? filename, string mime_type, int64 filesize,
|
||||||
int64 message_id, int64 attachment_id) {
|
int64 message_id, int64 attachment_id) {
|
||||||
|
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
|
|
@ -22,11 +22,13 @@ public class Geary.Attachment {
|
||||||
this.filepath = get_path(data_dir, message_id, attachment_id, filename);
|
this.filepath = get_path(data_dir, message_id, attachment_id, filename);
|
||||||
this.id = attachment_id;
|
this.id = attachment_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string get_path(File data_dir, int64 message_id, int64 attachment_id,
|
internal static string get_path(File data_dir, int64 message_id, int64 attachment_id,
|
||||||
string filename) {
|
string? filename) {
|
||||||
|
// "none" should not be translated, or the user will be unable to retrieve their
|
||||||
|
// attachments with no filenames after changing their language.
|
||||||
return "%s/attachments/%lld/%lld/%s".printf(data_dir.get_path(), message_id, attachment_id,
|
return "%s/attachments/%lld/%lld/%s".printf(data_dir.get_path(), message_id, attachment_id,
|
||||||
filename);
|
filename ?? "none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -668,10 +668,6 @@ private class Geary.Sqlite.Folder : Object, Geary.ReferenceSemantics {
|
||||||
// Get the info about the attachment.
|
// Get the info about the attachment.
|
||||||
string? filename = attachment.get_filename();
|
string? filename = attachment.get_filename();
|
||||||
string mime_type = attachment.get_content_type().to_string();
|
string mime_type = attachment.get_content_type().to_string();
|
||||||
if (filename == null || filename.length == 0) {
|
|
||||||
/// Placeholder filename for attachments with no filename.
|
|
||||||
filename = _("none");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the attachment content into a usable ByteArray.
|
// Convert the attachment content into a usable ByteArray.
|
||||||
GMime.DataWrapper attachment_data = attachment.get_content_object();
|
GMime.DataWrapper attachment_data = attachment.get_content_object();
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ public class Geary.Sqlite.MessageAttachmentRow : Geary.Sqlite.Row {
|
||||||
public int64 id { get; private set; }
|
public int64 id { get; private set; }
|
||||||
public int64 message_id { get; private set; }
|
public int64 message_id { get; private set; }
|
||||||
public int64 filesize { get; private set; }
|
public int64 filesize { get; private set; }
|
||||||
public string filename { get; private set; }
|
public string? filename { get; private set; }
|
||||||
public string mime_type { get; private set; }
|
public string mime_type { get; private set; }
|
||||||
|
|
||||||
public MessageAttachmentRow(MessageAttachmentTable table, int64 id, int64 message_id,
|
public MessageAttachmentRow(MessageAttachmentTable table, int64 id, int64 message_id,
|
||||||
string filename, string mime_type, int64 filesize) {
|
string? filename, string mime_type, int64 filesize) {
|
||||||
base (table);
|
base (table);
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue