Skip to content

Conversation

KeyWeeUsr
Copy link
Contributor

@KeyWeeUsr KeyWeeUsr commented Jan 2, 2024

Purpose

Making short deviceID length consistent and referencing to protocol file for future-proof edits. Closes #9313.

@@ -910,7 +910,7 @@ <h4 class="panel-title">
</tr>
<tr ng-if="deviceCfg.introducedBy">
<th><span class="far fa-fw fa-handshake-o"></span>&nbsp;<span translate>Introduced By</span></th>
<td class="text-right">{{ deviceName(devices[deviceCfg.introducedBy]) || deviceCfg.introducedBy.substring(0, 5) }}</td>
<td class="text-right">{{ deviceName(devices[deviceCfg.introducedBy]) || deviceCfg.introducedBy.substring(0, shortIDStringLength) }}</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function deviceName already returns a short-id if there is no name, so the or part here does nothing and can be removed. Then you don't need to add shortIDStringLength to $scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imsodin Should I really remove it? There seems to be handling for undefined with "" which is then handled by that || and that one isn't present in deviceName() 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, you are right - I misread that code. I was thinking the check was done on the same config, but it's devices[deviceCfg.introducedBy] vs plain deviceCfg afterwards. So lets leave the || part, however you can use the existing deviceShortID function instead without needing shortIDStringLength here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imsodin Fixed ✌️

Comment on lines 17 to 19
DeviceIDLength = 32
// keep consistent with shortIDStringLength in gui/default/syncthing/app.js
ShortIDStringLength = 7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the source of the CI failure: The added comment changes the alignment gofmt -S expects:

=== RUN   TestCheckGoFmt
    gofmt_test.go:39: File ../lib/protocol/deviceid.go is not formatted correctly:
        
        diff ../lib/protocol/deviceid.go.orig ../lib/protocol/deviceid.go
        --- ../lib/protocol/deviceid.go.orig
        +++ ../lib/protocol/deviceid.go
        @@ -14,7 +14,7 @@
         )
         
         const (
        -	DeviceIDLength      = 32
        +	DeviceIDLength = 32
         	// keep consistent with shortIDStringLength in gui/default/syncthing/app.js
         	ShortIDStringLength = 7
         )
--- FAIL: TestCheckGoFmt (1.20s)

https://github.com/syncthing/syncthing/actions/runs/7387700143/job/20096964099?pr=9314

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imsodin Fixed 👍

@imsodin imsodin changed the title gui, lib, next-gen-gui: Keep short deviceID length consistent + xrefs gui: Keep short deviceID length consistent + xrefs (fixes #9313) Jan 2, 2024
Copy link
Member

@imsodin imsodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@imsodin imsodin merged commit 2abfefc into syncthing:main Jan 2, 2024
@KeyWeeUsr KeyWeeUsr deleted the consistent-short-deviceids branch January 2, 2024 16:45
calmh added a commit to calmh/syncthing that referenced this pull request Jan 4, 2024
* main:
  Update dependencies (syncthing#9321)
  gui: Always inform about loading data in Restore Versions modal (syncthing#9317)
  lib/build: Allow semver build in version regex (fixes syncthing#9267) (syncthing#9316)
  gui: Keep short deviceID length consistent + xrefs (fixes syncthing#9313) (syncthing#9314)
  build(deps): bump actions/download-artifact from 3 to 4 (syncthing#9294)
  build(deps): bump actions/upload-artifact from 3 to 4 (syncthing#9293)
  gui, man, authors: Update docs, translations, and contributors
  gui, lib/scanner: Improve scan progress indication (ref syncthing#8331) (syncthing#9308)
  lib/protocol: handle empty names in unixOwnershipEqual (fixes syncthing#9039) (syncthing#9306)
  gui, man, authors: Update docs, translations, and contributors
  etc/linux-desktop: use double dash for long options (syncthing#9301)
  lib/connections: Skip allocation in check for missing port (syncthing#9297)
  lib/upgrade: Extract signing key to embedded file (fixes syncthing#9247) (syncthing#9296)
  gui, man, authors: Update docs, translations, and contributors
  build: Update quic-go (fixes syncthing#9287)
  lib/model: Only handle relevant folder summaries (kqueue) (fixes syncthing#9183) (syncthing#9288)
calmh added a commit to danpadcz/syncthing that referenced this pull request Jan 4, 2024
* main:
  Update dependencies (syncthing#9321)
  gui: Always inform about loading data in Restore Versions modal (syncthing#9317)
  lib/build: Allow semver build in version regex (fixes syncthing#9267) (syncthing#9316)
  gui: Keep short deviceID length consistent + xrefs (fixes syncthing#9313) (syncthing#9314)
  build(deps): bump actions/download-artifact from 3 to 4 (syncthing#9294)
  build(deps): bump actions/upload-artifact from 3 to 4 (syncthing#9293)
  gui, man, authors: Update docs, translations, and contributors
  gui, lib/scanner: Improve scan progress indication (ref syncthing#8331) (syncthing#9308)
  lib/protocol: handle empty names in unixOwnershipEqual (fixes syncthing#9039) (syncthing#9306)
  gui, man, authors: Update docs, translations, and contributors
  etc/linux-desktop: use double dash for long options (syncthing#9301)
  lib/connections: Skip allocation in check for missing port (syncthing#9297)
  lib/upgrade: Extract signing key to embedded file (fixes syncthing#9247) (syncthing#9296)
  gui, man, authors: Update docs, translations, and contributors
  build: Update quic-go (fixes syncthing#9287)
  lib/model: Only handle relevant folder summaries (kqueue) (fixes syncthing#9183) (syncthing#9288)
@calmh calmh added this to the v1.27.3 milestone Jan 4, 2024
calmh added a commit to calmh/syncthing that referenced this pull request Jan 14, 2024
* main: (24 commits)
  lib/ignore: Refactor out result type (syncthing#9343)
  build: Testing infra images for infra-* branches
  lib/versioner: Expand tildes in version directory (fixes syncthing#9241) (syncthing#9327)
  lib/scanner: Prevent sync-conflict for receive-only local modifications  (syncthing#9323)
  gui, man, authors: Update docs, translations, and contributors
  Fix website security link in README.md (syncthing#9325)
  cmd/syncthing: Add CLI completion functionality (fixes syncthing#8616) (syncthing#9226)
  lib/api: Save session & CSRF tokens to database, add option to stay logged in (fixes syncthing#9151) (syncthing#9284)
  Update dependencies (syncthing#9321)
  gui: Always inform about loading data in Restore Versions modal (syncthing#9317)
  lib/build: Allow semver build in version regex (fixes syncthing#9267) (syncthing#9316)
  gui: Keep short deviceID length consistent + xrefs (fixes syncthing#9313) (syncthing#9314)
  build(deps): bump actions/download-artifact from 3 to 4 (syncthing#9294)
  build(deps): bump actions/upload-artifact from 3 to 4 (syncthing#9293)
  gui, man, authors: Update docs, translations, and contributors
  gui, lib/scanner: Improve scan progress indication (ref syncthing#8331) (syncthing#9308)
  lib/protocol: handle empty names in unixOwnershipEqual (fixes syncthing#9039) (syncthing#9306)
  gui, man, authors: Update docs, translations, and contributors
  etc/linux-desktop: use double dash for long options (syncthing#9301)
  lib/connections: Skip allocation in check for missing port (syncthing#9297)
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Apr 9, 2025
@syncthing syncthing locked and limited conversation to collaborators Apr 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different lengths used for short device IDs in UI
4 participants