Skip to content

Commit

Permalink
Deprecate file:subfile:name and add :path=<file:path> property. (#2043)
Browse files Browse the repository at this point in the history
Deprecate file:subfile:name for file:subfile:path
  • Loading branch information
invisig0th authored Jan 11, 2021
1 parent 1a1f5fe commit cce6f10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions synapse/models/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,12 @@ def getModelDefs(self):
'doc': 'The child file contained in the parent file.',
}),
('name', ('file:base', {}), {
'doc': 'The name of the child file. Because a given set of bytes '
'can have any number of arbitrary names, this field is '
'used for display purposes only.'
})
'deprecated': True,
'doc': 'Deprecated, please use the :path property.',
}),
('path', ('file:path', {}), {
'doc': 'The path that the parent uses to refer to the child file.',
}),
)),

('file:path', {}, (
Expand Down
3 changes: 2 additions & 1 deletion synapse/tests/test_model_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ async def test_model_file_types(self):
fake = await snap.addNode('file:bytes', '*')
self.true(fake.ndef[1].startswith('guid:'))

node = await snap.addNode('file:subfile', (node1.ndef[1], node2.ndef[1]), {'name': 'embed.BIN'})
node = await snap.addNode('file:subfile', (node1.ndef[1], node2.ndef[1]), {'name': 'embed.BIN', 'path': 'foo/embed.bin'})
self.eq(node.ndef[1], (node1.ndef[1], node2.ndef[1]))
self.eq(node.get('parent'), node1.ndef[1])
self.eq(node.get('child'), node2.ndef[1])
self.eq(node.get('name'), 'embed.bin')
self.eq(node.get('path'), 'foo/embed.bin')

fp = 'C:\\www\\woah\\really\\sup.exe'
node = await snap.addNode('file:filepath', (node0.ndef[1], fp))
Expand Down

0 comments on commit cce6f10

Please sign in to comment.