refactor - redraw diag, rename methods.

pull/1/head
Ivan Olexyn 4 years ago
parent efd9313885
commit 4a99d7a11a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

@ -4,13 +4,14 @@
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1070</x> <x>840</x>
<y>500</y> <y>430</y>
<w>120</w> <w>120</w>
<h>40</h> <h>60</h>
</coordinates> </coordinates>
<panel_attributes>make <panel_attributes>makeList
ListCreated OfLocally
CreatedFiles
halign=left halign=left
transparency=0</panel_attributes> transparency=0</panel_attributes>
<additional_attributes/> <additional_attributes/>
@ -18,13 +19,14 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1070</x> <x>840</x>
<y>540</y> <y>490</y>
<w>120</w> <w>120</w>
<h>40</h> <h>60</h>
</coordinates> </coordinates>
<panel_attributes>make <panel_attributes>makeList
ListDeleted OfLocally
DeletedFiles
halign=left halign=left
transparency=0</panel_attributes> transparency=0</panel_attributes>
<additional_attributes/> <additional_attributes/>
@ -32,27 +34,29 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>760</x> <x>840</x>
<y>650</y> <y>610</y>
<w>120</w> <w>120</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>doCreate <panel_attributes>doCreateOps
OnOtherSDs
halign=left halign=left
style=wordwrap style=wordwrap
transparency=0 transparency=0
transparency=0</panel_attributes> bg=#81D4FA</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1270</x> <x>1050</x>
<y>310</y> <y>270</y>
<w>120</w> <w>120</w>
<h>50</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>read StateFile <panel_attributes>read
StateFile
bg=#FFF59D bg=#FFF59D
halign=left halign=left
style=wordwrap style=wordwrap
@ -62,13 +66,14 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1070</x> <x>840</x>
<y>580</y> <y>550</y>
<w>120</w> <w>120</w>
<h>40</h> <h>60</h>
</coordinates> </coordinates>
<panel_attributes>make <panel_attributes>makeList
ListModified OfLocally
ModifiedFiles
halign=left halign=left
transparency=0</panel_attributes> transparency=0</panel_attributes>
<additional_attributes/> <additional_attributes/>
@ -76,12 +81,13 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1070</x> <x>840</x>
<y>410</y> <y>380</y>
<w>120</w> <w>120</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>readState <panel_attributes>readState
FromFS
bg=#A5D6A7 bg=#A5D6A7
halign=left halign=left
style=wordwrap style=wordwrap
@ -91,25 +97,27 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>750</x> <x>840</x>
<y>260</y> <y>200</y>
<w>120</w> <w>120</w>
<h>30</h> <h>30</h>
</coordinates> </coordinates>
<panel_attributes>START <panel_attributes>START
bg=#B0BEC5 bg=#B0BEC5
transparency=0
style=wordwrap</panel_attributes> style=wordwrap</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>1070</x> <x>840</x>
<y>800</y> <y>760</y>
<w>120</w> <w>120</w>
<h>50</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>write StateFile <panel_attributes>write
StateFile
bg=#FFF59D bg=#FFF59D
halign=left halign=left
style=wordwrap style=wordwrap
@ -119,36 +127,40 @@ transparency=0</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>760</x> <x>840</x>
<y>690</y> <y>660</y>
<w>120</w> <w>120</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>doDelete <panel_attributes>doDeleteOps
OnOtherSDs
halign=left halign=left
style=wordwrap style=wordwrap
transparency=0</panel_attributes> transparency=0
bg=#81D4FA</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>760</x> <x>840</x>
<y>730</y> <y>710</y>
<w>120</w> <w>120</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>doModify <panel_attributes>doModifyOps
OnOtherSDs
halign=left halign=left
style=wordwrap style=wordwrap
transparency=0</panel_attributes> transparency=0
bg=#81D4FA</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>UMLSpecialState</id> <id>UMLSpecialState</id>
<coordinates> <coordinates>
<x>1310</x> <x>1090</x>
<y>410</y> <y>380</y>
<w>40</w> <w>40</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
@ -159,101 +171,78 @@ transparency=0</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1320</x> <x>1100</x>
<y>350</y> <y>310</y>
<w>30</w> <w>30</w>
<h>80</h> <h>90</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;-</panel_attributes> <panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>10.0;60.0;10.0;10.0</additional_attributes> <additional_attributes>10.0;70.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1180</x> <x>950</x>
<y>440</y> <y>410</y>
<w>170</w> <w>180</w>
<h>400</h> <h>390</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;-</panel_attributes> <panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>10.0;380.0;150.0;380.0;150.0;10.0</additional_attributes> <additional_attributes>10.0;370.0;160.0;370.0;160.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1180</x> <x>950</x>
<y>410</y> <y>380</y>
<w>150</w> <w>160</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>10.0;20.0;130.0;20.0</additional_attributes> <additional_attributes>10.0;20.0;140.0;20.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>600</x> <x>780</x>
<y>260</y> <y>200</y>
<w>180</w> <w>80</w>
<h>680</h> <h>650</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;-</panel_attributes> <panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>150.0;10.0;10.0;10.0;10.0;660.0;160.0;660.0</additional_attributes> <additional_attributes>60.0;10.0;10.0;10.0;10.0;630.0;60.0;630.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>870</x>
<y>740</y>
<w>280</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>260.0;60.0;260.0;10.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>760</x> <x>840</x>
<y>900</y> <y>810</y>
<w>120</w> <w>120</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>Sleep <panel_attributes>SLEEP
style=wordwrap style=wordwrap
bg=#B0BEC5
transparency=0</panel_attributes> transparency=0</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>870</x> <x>910</x>
<y>840</y> <y>280</y>
<w>280</w> <w>160</w>
<h>100</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>10.0;80.0;260.0;80.0;260.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>1140</x>
<y>320</y>
<w>150</w>
<h>30</h> <h>30</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;-</panel_attributes> <panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>130.0;10.0;10.0;10.0</additional_attributes> <additional_attributes>140.0;10.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>UMLSpecialState</id> <id>UMLSpecialState</id>
<coordinates> <coordinates>
<x>1110</x> <x>880</x>
<y>310</y> <y>270</y>
<w>40</w> <w>40</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
@ -264,8 +253,8 @@ transparency=0</panel_attributes>
<element> <element>
<id>Text</id> <id>Text</id>
<coordinates> <coordinates>
<x>1240</x> <x>980</x>
<y>470</y> <y>450</y>
<w>110</w> <w>110</w>
<h>50</h> <h>50</h>
</coordinates> </coordinates>
@ -276,19 +265,19 @@ StateFile]</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1120</x> <x>890</x>
<y>340</y> <y>300</y>
<w>30</w> <w>30</w>
<h>90</h> <h>100</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;-</panel_attributes> <panel_attributes>lt=&lt;-</panel_attributes>
<additional_attributes>10.0;70.0;10.0;10.0</additional_attributes> <additional_attributes>10.0;80.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>Text</id> <id>Text</id>
<coordinates> <coordinates>
<x>1030</x> <x>790</x>
<y>360</y> <y>330</y>
<w>110</w> <w>110</w>
<h>30</h> <h>30</h>
</coordinates> </coordinates>
@ -298,20 +287,20 @@ StateFile]</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>860</x> <x>890</x>
<y>260</y> <y>220</y>
<w>290</w> <w>30</w>
<h>70</h> <h>70</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>270.0;50.0;270.0;10.0;10.0;10.0</additional_attributes> <additional_attributes>10.0;50.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>Text</id> <id>Text</id>
<coordinates> <coordinates>
<x>1150</x> <x>920</x>
<y>300</y> <y>250</y>
<w>130</w> <w>130</w>
<h>30</h> <h>30</h>
</coordinates> </coordinates>
@ -321,8 +310,8 @@ StateFile]</panel_attributes>
<element> <element>
<id>Text</id> <id>Text</id>
<coordinates> <coordinates>
<x>1200</x> <x>970</x>
<y>390</y> <y>340</y>
<w>100</w> <w>100</w>
<h>50</h> <h>50</h>
</coordinates> </coordinates>
@ -330,39 +319,16 @@ StateFile]</panel_attributes>
exists]</panel_attributes> exists]</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element>
<id>Relation</id>
<coordinates>
<x>870</x>
<y>610</y>
<w>280</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>10.0;60.0;260.0;60.0;260.0;10.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>1120</x>
<y>440</y>
<w>30</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;-
</panel_attributes>
<additional_attributes>10.0;60.0;10.0;10.0</additional_attributes>
</element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>870</x> <x>1320</x>
<y>1040</y> <y>750</y>
<w>250</w> <w>150</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>add/remove Collection (Map) <panel_attributes>add/remove
Collection (Map)
halign=left halign=left
style=wordwrap style=wordwrap
bg=#B39DDB</panel_attributes> bg=#B39DDB</panel_attributes>
@ -371,8 +337,8 @@ bg=#B39DDB</panel_attributes>
<element> <element>
<id>UMLSpecialState</id> <id>UMLSpecialState</id>
<coordinates> <coordinates>
<x>800</x> <x>1270</x>
<y>1040</y> <y>810</y>
<w>40</w> <w>40</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
@ -382,60 +348,61 @@ bg=#B39DDB</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>810</x> <x>950</x>
<y>930</y> <y>810</y>
<w>30</w> <w>340</w>
<h>130</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>10.0;110.0;10.0;10.0</additional_attributes> <additional_attributes>320.0;20.0;10.0;20.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>830</x> <x>1280</x>
<y>1040</y> <y>760</y>
<w>60</w> <w>60</w>
<h>40</h> <h>70</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>40.0;20.0;10.0;20.0</additional_attributes> <additional_attributes>40.0;20.0;10.0;20.0;10.0;50.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>800</x> <x>950</x>
<y>220</y> <y>190</y>
<w>680</w> <w>590</w>
<h>840</h> <h>590</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>10.0;40.0;10.0;20.0;660.0;20.0;660.0;820.0</additional_attributes> <additional_attributes>10.0;20.0;570.0;20.0;570.0;570.0</additional_attributes>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>810</x> <x>1280</x>
<y>1070</y> <y>840</y>
<w>80</w> <w>60</w>
<h>70</h> <h>60</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>60.0;50.0;10.0;50.0;10.0;10.0</additional_attributes> <additional_attributes>40.0;40.0;10.0;40.0;10.0;10.0</additional_attributes>
</element> </element>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>870</x> <x>1320</x>
<y>1100</y> <y>860</y>
<w>250</w> <w>150</w>
<h>40</h> <h>50</h>
</coordinates> </coordinates>
<panel_attributes>add/remove Directory <panel_attributes>add/remove
Directory
halign=left halign=left
style=wordwrap style=wordwrap
bg=#B39DDB</panel_attributes> bg=#B39DDB</panel_attributes>
@ -444,20 +411,20 @@ bg=#B39DDB</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1110</x> <x>1460</x>
<y>1040</y> <y>760</y>
<w>350</w> <w>60</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>330.0;20.0;10.0;20.0</additional_attributes> <additional_attributes>40.0;20.0;10.0;20.0</additional_attributes>
</element> </element>
<element> <element>
<id>UMLSpecialState</id> <id>UMLSpecialState</id>
<coordinates> <coordinates>
<x>1440</x> <x>1500</x>
<y>1040</y> <y>760</y>
<w>40</w> <w>40</w>
<h>40</h> <h>40</h>
</coordinates> </coordinates>
@ -467,20 +434,20 @@ bg=#B39DDB</panel_attributes>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>1110</x> <x>1460</x>
<y>1070</y> <y>790</y>
<w>370</w> <w>80</w>
<h>70</h> <h>110</h>
</coordinates> </coordinates>
<panel_attributes>lt=&lt;- <panel_attributes>lt=&lt;-
</panel_attributes> </panel_attributes>
<additional_attributes>350.0;10.0;350.0;50.0;10.0;50.0</additional_attributes> <additional_attributes>60.0;10.0;60.0;90.0;10.0;90.0</additional_attributes>
</element> </element>
<element> <element>
<id>Text</id> <id>Text</id>
<coordinates> <coordinates>
<x>870</x> <x>1060</x>
<y>1010</y> <y>800</y>
<w>160</w> <w>160</w>
<h>30</h> <h>30</h>
</coordinates> </coordinates>
@ -490,10 +457,10 @@ bg=#B39DDB</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>440</x> <x>490</x>
<y>160</y> <y>90</y>
<w>1060</w> <w>730</w>
<h>820</h> <h>850</h>
</coordinates> </coordinates>
<panel_attributes> <panel_attributes>
* Logic-Thread* * Logic-Thread*
@ -506,10 +473,10 @@ lt=.</panel_attributes>
<element> <element>
<id>UMLState</id> <id>UMLState</id>
<coordinates> <coordinates>
<x>440</x> <x>1240</x>
<y>990</y> <y>680</y>
<w>1060</w> <w>340</w>
<h>180</h> <h>260</h>
</coordinates> </coordinates>
<panel_attributes> <panel_attributes>
* UI-Thread* * UI-Thread*
@ -520,72 +487,69 @@ lt=.</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>UMLNote</id> <id>UMLClass</id>
<coordinates> <coordinates>
<x>630</x> <x>740</x>
<y>660</y> <y>120</y>
<w>110</w> <w>460</w>
<h>90</h> <h>770</h>
</coordinates> </coordinates>
<panel_attributes>Compare the Lists of the different Directories <panel_attributes>*SyncDirectory*
transparency=0</panel_attributes> lw=2.5</panel_attributes>
<additional_attributes/> <additional_attributes/>
</element> </element>
<element> <element>
<id>Relation</id> <id>UMLClass</id>
<coordinates> <coordinates>
<x>730</x> <x>510</x>
<y>660</y> <y>370</y>
<w>50</w> <w>150</w>
<h>50</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>lt=.</panel_attributes> <panel_attributes>*SyncMap*
<additional_attributes>30.0;10.0;10.0;30.0</additional_attributes> bg=#81D4FA
lw=2.5</panel_attributes>
<additional_attributes/>
</element> </element>
<element> <element>
<id>Relation</id> <id>UMLClass</id>
<coordinates> <coordinates>
<x>730</x> <x>510</x>
<y>700</y> <y>240</y>
<w>50</w> <w>150</w>
<h>30</h> <h>40</h>
</coordinates> </coordinates>
<panel_attributes>lt=.</panel_attributes> <panel_attributes>*MAP_OF_SYNCMAPS*
<additional_attributes>30.0;10.0;10.0;10.0</additional_attributes> bg=#B0BEC5
transparency=0
lw=2.5</panel_attributes>
<additional_attributes/>
</element> </element>
<element> <element>
<id>Relation</id> <id>Relation</id>
<coordinates> <coordinates>
<x>730</x> <x>570</x>
<y>720</y> <y>270</y>
<w>50</w> <w>60</w>
<h>50</h> <h>120</h>
</coordinates>
<panel_attributes>lt=.</panel_attributes>
<additional_attributes>30.0;30.0;10.0;10.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>1010</x>
<y>190</y>
<w>420</w>
<h>770</h>
</coordinates> </coordinates>
<panel_attributes>SyncDirectory <panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-
bg=#F6F6F6</panel_attributes> m1=1
<additional_attributes/> m2=0..n</panel_attributes>
<additional_attributes>10.0;10.0;10.0;100.0</additional_attributes>
</element> </element>
<element> <element>
<id>UMLClass</id> <id>Relation</id>
<coordinates> <coordinates>
<x>700</x> <x>570</x>
<y>190</y> <y>400</y>
<w>230</w> <w>190</w>
<h>770</h> <h>110</h>
</coordinates> </coordinates>
<panel_attributes>SyncMap <panel_attributes>lt=&lt;&lt;&lt;&lt;&lt;-
bg=#F6F6F6</panel_attributes> m1=1
<additional_attributes/> m2=0..n
layer=2</panel_attributes>
<additional_attributes>10.0;10.0;10.0;80.0;170.0;80.0</additional_attributes>
</element> </element>
</diagram> </diagram>

@ -4,7 +4,6 @@ import com.olexyn.ensync.artifacts.SyncDirectory;
import com.olexyn.ensync.artifacts.SyncMap; import com.olexyn.ensync.artifacts.SyncMap;
import java.io.File; import java.io.File;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import static com.olexyn.ensync.Main.MAP_OF_SYNCMAPS; import static com.olexyn.ensync.Main.MAP_OF_SYNCMAPS;
@ -45,15 +44,15 @@ public class Flow implements Runnable {
private void doSyncDirectory(SyncDirectory SD) { private void doSyncDirectory(SyncDirectory SD) {
state = "READ"; state = "READ";
SD.readFreshState(); SD.readStateFromFS();
SD.listCreated = SD.makeListCreated(); SD.listCreated = SD.makeListOfLocallyCreatedFiles();
SD.listDeleted = SD.makeListDeleted(); SD.listDeleted = SD.makeListOfLocallyDeletedFiles();
SD.listModified = SD.makeListModified(); SD.listModified = SD.makeListOfLocallyModifiedFiles();
SD.doCreate(); SD.doCreateOpsOnOtherSDs();
SD.doDelete(); SD.doDeleteOpsOnOtherSDs();
SD.doModify(); SD.doModifyOpsOnOtherSDs();
SD.writeStateFile(SD.path); SD.writeStateFile(SD.path);
} }

@ -45,12 +45,14 @@ public class SyncDirectory {
/** /**
* Get the current state by using the `find` command. * Get the current state by using the `find` command.
*/ */
public Map<String, SyncFile> readFreshState() { public Map<String, SyncFile> readStateFromFS() {
//NOTE that the SFile().lastModifiedOld is not set here, so it is 0 by default. //NOTE that the SFile().lastModifiedOld is not set here, so it is 0 by default.
Map<String, SyncFile> filemap = new HashMap<>(); Map<String, SyncFile> filemap = new HashMap<>();
Execute.TwoBr find = x.execute(new String[]{"find", Execute.TwoBr find = x.execute(new String[]{
path}); "find",
path
});
List<String> pathList = tools.brToListString(find.output); List<String> pathList = tools.brToListString(find.output);
@ -90,9 +92,9 @@ public class SyncDirectory {
* Compare the OLD and NEW pools. * Compare the OLD and NEW pools.
* List is cleared and created each time. * List is cleared and created each time.
*/ */
public Map<String, SyncFile> makeListCreated() { public Map<String, SyncFile> makeListOfLocallyCreatedFiles() {
Map<String, SyncFile> fromA = readFreshState(); Map<String, SyncFile> fromA = readStateFromFS();
Map<String, SyncFile> substractB = readStateFile(); Map<String, SyncFile> substractB = readStateFile();
return tools.mapMinus(fromA, substractB); return tools.mapMinus(fromA, substractB);
@ -103,10 +105,10 @@ public class SyncDirectory {
* Compare the OLD and NEW pools. * Compare the OLD and NEW pools.
* List is cleared and created each time. * List is cleared and created each time.
*/ */
public Map<String, SyncFile> makeListDeleted() { public Map<String, SyncFile> makeListOfLocallyDeletedFiles() {
Map<String, SyncFile> fromA = readStateFile(); Map<String, SyncFile> fromA = readStateFile();
Map<String, SyncFile> substractB = readFreshState(); Map<String, SyncFile> substractB = readStateFromFS();
Map<String, SyncFile> listDeleted = tools.mapMinus(fromA, substractB); Map<String, SyncFile> listDeleted = tools.mapMinus(fromA, substractB);
@ -131,13 +133,13 @@ public class SyncDirectory {
* Compare the OLD and NEW pools. * Compare the OLD and NEW pools.
* List is cleared and created each time. * List is cleared and created each time.
*/ */
public Map<String, SyncFile> makeListModified() { public Map<String, SyncFile> makeListOfLocallyModifiedFiles() {
Map<String, SyncFile> listModified = new HashMap<>(); Map<String, SyncFile> listModified = new HashMap<>();
Map<String, SyncFile> stateFileMap = readStateFile(); Map<String, SyncFile> stateFileMap = readStateFile();
for (var freshFileEntry : readFreshState().entrySet()) { for (var freshFileEntry : readStateFromFS().entrySet()) {
String freshFileKey = freshFileEntry.getKey(); String freshFileKey = freshFileEntry.getKey();
SyncFile freshFile = freshFileEntry.getValue(); SyncFile freshFile = freshFileEntry.getValue();
@ -206,7 +208,7 @@ public class SyncDirectory {
} }
public void doCreate() { public void doCreateOpsOnOtherSDs() {
for (var entry : listCreated.entrySet()) { for (var entry : listCreated.entrySet()) {
SyncFile createdFile = entry.getValue(); SyncFile createdFile = entry.getValue();
@ -218,7 +220,7 @@ public class SyncDirectory {
Info info = new Info(this, createdFile, otherSD); Info info = new Info(this, createdFile, otherSD);
writeFile(info, this, createdFile, otherSD); writeFileIfNewer(info, createdFile, otherSD);
} }
} }
} }
@ -227,7 +229,7 @@ public class SyncDirectory {
/** /**
* *
*/ */
public void doDelete() { public void doDeleteOpsOnOtherSDs() {
for (var entry : listDeleted.entrySet()) { for (var entry : listDeleted.entrySet()) {
SyncFile deletedFile = entry.getValue(); SyncFile deletedFile = entry.getValue();
@ -262,7 +264,7 @@ public class SyncDirectory {
} }
public void doModify() { public void doModifyOpsOnOtherSDs() {
for (var entry : listModified.entrySet()) { for (var entry : listModified.entrySet()) {
SyncFile modifiedFile = entry.getValue(); SyncFile modifiedFile = entry.getValue();
@ -274,20 +276,23 @@ public class SyncDirectory {
Info info = new Info(this, modifiedFile, otherSD); Info info = new Info(this, modifiedFile, otherSD);
writeFile(info, this, modifiedFile, otherSD); writeFileIfNewer(info, modifiedFile, otherSD);
} }
} }
} }
/***
private void writeFile(Info info, SyncDirectory thisSD, SyncFile thisFile, SyncDirectory otherSD) { *
* @param info
* @param thisFile
* @param otherSD
*/
private void writeFileIfNewer(Info info, SyncFile thisFile, SyncDirectory otherSD) {
SyncFile otherFile = new SyncFile(otherSD, otherSD.path + thisFile.relativePath); SyncFile otherFile = new SyncFile(otherSD, otherSD.path + thisFile.relativePath);
if (otherFile.exists() && thisFile.getTimeModified() < otherFile.getTimeModified()) { return;} if (otherFile.exists() && thisFile.getTimeModified() < otherFile.getTimeModified()) { return;}
if (thisFile.isDirectory() && !otherFile.exists()) { if (thisFile.isDirectory() && !otherFile.exists()) {
List<String> cmd = List.of("mkdir", "-p", info.otherFilePath); List<String> cmd = List.of("mkdir", "-p", info.otherFilePath);
x.execute(cmd); x.execute(cmd);
@ -296,11 +301,8 @@ public class SyncDirectory {
if (thisFile.isFile()) { if (thisFile.isFile()) {
if (!info.otherParentFile.exists()) { if (!info.otherParentFile.exists()) {
makeParentChain(otherFile, thisFile); makeParentChain(otherFile, thisFile);
// List<String> cmd = List.of("mkdir", "-p", info.otherParentPath);
//x.execute(cmd);
} }
List<String> cmd = List.of("cp", "-p", info.thisFilePath, info.otherFilePath); List<String> cmd = List.of("cp", "-p", info.thisFilePath, info.otherFilePath);
@ -309,7 +311,10 @@ public class SyncDirectory {
} }
} }
/**
* @param otherFile
* @param thisFile
*/
private void makeParentChain(File otherFile, File thisFile) { private void makeParentChain(File otherFile, File thisFile) {
try { try {
File otherParent = new File(otherFile.getParent()); File otherParent = new File(otherFile.getParent());

Loading…
Cancel
Save