Commit 22d7095d authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

[bfss] Make ``current_fs_path`` return None when an attribute has no value

current_fs_path was returning the future fspath when no value was defined.

* This does not make any sense
* This tricks the storage into believing that updating the attribute content is
  not necessary. The file was written but the attributes was not updated. as a
  result the assignement was not made.

(close #1725446)

branch : stable
parent 195b24fe3a03
......@@ -173,12 +173,14 @@ class BytesFileSystemStorage(Storage):
entity.cw_edited.edited_attribute(attr, Binary(fpath))
# Mark the old file as useless so the file will be removed at
# commit.
if oldpath is not None:
return binary
def entity_deleted(self, entity, attr):
"""an entity using this storage for attr has been deleted"""
fpath = self.current_fs_path(entity, attr)
if fpath is not None:
def new_fs_path(self, entity, attr):
......@@ -199,13 +201,16 @@ class BytesFileSystemStorage(Storage):
return fspath
def current_fs_path(self, entity, attr):
"""return the current fs_path of the tribute.
Return None is the attr is not stored yet."""
sysource = entity._cw.pool.source('system')
cu = sysource.doexec(entity._cw,
'SELECT cw_%s FROM cw_%s WHERE cw_eid=%s' % (
attr, entity.__regid__, entity.eid))
rawvalue = cu.fetchone()[0]
if rawvalue is None: # no previous value
return self.new_fs_path(entity, attr)
return None
return sysource._process_value(rawvalue, cu.description[0],
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment