Ticket #2229 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

metadata-only update sets filesize property to 0

Reported by: garycmartin Owned by: aa
Priority: Unspecified by Maintainer Milestone: 0.90
Component: sugar-datastore Version: 0.90.x
Severity: Major Keywords: dextrose
Cc: aa, alsroot Distribution/OS:
Bug Status: Assigned

Description

Testing the latest dextrose 373pyg, when setting the Journal sort option to "View by size" and editing the name of any entry, it's size is reset to "Empty". Only by resuming the entry will the size correctly show again.

Steps to reproduce:

- switch to Journal
- right click on the "Sort by" icon (FWIW 373pyg has the button incorrectly labeled "List view")
- select "View by size"
- click on the text name of any Journal entry to edit it
- press return to OK the edit (don't actually need to change the text)
- the Journal entry will now show as size "Empty"

Attachments

Journal renaming sets size to Empty.png Download (63.1 KB) - added by garycmartin 3 years ago.
Note the renamed screenshot entries are all now showing "Empty", they were showing the correct size before being renamed.
2229-journal-rename-sets-size-to-empty.patch Download (0.8 KB) - added by aa 3 years ago.

Change History

Changed 3 years ago by garycmartin

Note the renamed screenshot entries are all now showing "Empty", they were showing the correct size before being renamed.

follow-up: ↓ 3   Changed 3 years ago by erikos

Thanks for your report, Gary! Reproduced with the latest patches here.

- right click on the "Sort by" icon (FWIW 373pyg has the button incorrectly labeled "List view")

What would be the correct labeling here?

  Changed 3 years ago by alsroot

  • cc aa added

in reply to: ↑ 1 ; follow-up: ↓ 4   Changed 3 years ago by garycmartin

Replying to erikos:

Thanks for your report, Gary! Reproduced with the latest patches here.

{{{
- right click on the "Sort by" icon (FWIW 373pyg has the button incorrectly labeled "List view")
}}}

What would be the correct labeling here?

Sorry, you're going to hate me, but you did ask ;)

Sort view


Sort by date modified
Sort by date created
Sort by size

in reply to: ↑ 3   Changed 3 years ago by erikos

Replying to garycmartin:

Replying to erikos:

Thanks for your report, Gary! Reproduced with the latest patches here.

{{{
- right click on the "Sort by" icon (FWIW 373pyg has the button incorrectly labeled "List view")
}}}

What would be the correct labeling here?


Sorry, you're going to hate me, but you did ask ;)

Sort view
------------
Sort by date modified
Sort by date created
Sort by size

Those are easy changes - attached screenshot to other ticket.

  Changed 3 years ago by erikos

  • owner changed from alsroot to aa
  • status changed from new to assigned
  • status_field changed from Unconfirmed to Assigned
  • milestone changed from Unspecified by Release Team to 0.90

Changed 3 years ago by aa

follow-up: ↓ 7   Changed 3 years ago by aa

  • cc alsroot added
  • keywords dextrose, r? added; dextrose removed

This bug is caused by the journal calling model.write with a default file_path argument:

    def __cell_title_edited_cb(self, cell, path, new_text):
        row = self._model[path]
        metadata = model.get(row[ListModel.COLUMN_UID])
        metadata['title'] = new_text
        model.write(metadata, update_mtime=False)
        self.cell_title.props.editable = False

The default_file path is , and so the filesize is updated with an inexistent file.

def write(metadata, file_path='', update_mtime=True, transfer_ownership=True):
...
         if metadata.get('uid', ''):
             object_id = _get_datastore().update(metadata['uid'],
                                                  dbus.Dictionary(metadata),
                                                  file_path,
                                                  transfer_ownership)

The attached patch fixes this.

in reply to: ↑ 6   Changed 3 years ago by sascha_silbe

  • keywords dextrose added; dextrose, r? removed
  • distribution Unspecified deleted
  • version changed from Unspecified to 0.90.x
  • component changed from journal to sugar-datastore
  • summary changed from Using Journal to rename an entry sets entry size to "Empty" when sort mode is "View by size" to metadata-only update sets filesize property to 0

Replying to aa:

The default_file path is , and so the filesize is updated with an inexistent file.

That's a bug in the data store then. Passing file_path= for an entry that already has data means updating the metadata only and leaving the data unchanged (see  carquinyol.filestore.FileStore.store(); especially notice the commented out part).
If we change the API to not support metadata-only updates anymore, more than just the Journal will break.

  Changed 3 years ago by alsroot

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.