<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23567">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pySim-shell: prevent inconsitancy when walking through the FS tree<br><br>When using the method walk() to walk through the filesystem tree, then<br>the action() callback must not change the currently selected file.<br>Unfortunately this can easily happen and result in unpredictable<br>behavior. Lets add a check + an exeception for this to make debugging<br>easier.<br><br>Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c<br>Related: OS#4963<br>---<br>M pySim-shell.py<br>1 file changed, 7 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/67/23567/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim-shell.py b/pySim-shell.py</span><br><span>index 11953eb..2ac0b26 100755</span><br><span>--- a/pySim-shell.py</span><br><span>+++ b/pySim-shell.py</span><br><span>@@ -263,7 +263,14 @@</span><br><span>                                 self.walk(indent + 1, action, context)</span><br><span>                               fcp_dec = self._cmd.rs.select("..", self._cmd)</span><br><span>                     elif action:</span><br><span style="color: hsl(120, 100%, 40%);">+                          df_before_action = self._cmd.rs.selected_file</span><br><span>                                action(f, context)</span><br><span style="color: hsl(120, 100%, 40%);">+                            # When walking through the file system tree the action must not</span><br><span style="color: hsl(120, 100%, 40%);">+                               # always restore the currently selected file to the file that</span><br><span style="color: hsl(120, 100%, 40%);">+                         # was selected before executing the action() callback.</span><br><span style="color: hsl(120, 100%, 40%);">+                                if df_before_action != self._cmd.rs.selected_file:</span><br><span style="color: hsl(120, 100%, 40%);">+                                    raise RuntimeError("inconsistant walk, %s is currently selected but expecting %s to be selected"</span><br><span style="color: hsl(120, 100%, 40%);">+                                                       % (str(self._cmd.rs.selected_file), str(df_before_action)))</span><br><span> </span><br><span>   def do_tree(self, opts):</span><br><span>             """Display a filesystem-tree with all selectable files"""</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23567">change 23567</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/23567"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c </div>
<div style="display:none"> Gerrit-Change-Number: 23567 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>