sandstorm / synco

Synco - an Database and File Dump Downloader for synchronizing production, staging, and local development. Batteries included, but removable.
https://sandstorm.github.io/synco
MIT License
26 stars 2 forks source link

Runtime error when extracting all resources from folder #33

Open klfman opened 1 year ago

klfman commented 1 year ago

curl https://sandstorm.github.io/synco/serve | sh -s - just works, but when I try and download all files with curl https://sandstorm.github.io/synco/serve | sh -s - --all, the application crashes with a runtime error:

     INFO  collection 'persistent' is using target 'localWebDirectoryPersistentResourcesTarget'
     INFO  target 'localWebDirectoryPersistentResourcesTarget' is configured as follows: '{Target:Neos\Flow\ResourceManagement\Target\FileSystemSymlinkTarget TargetOptions:{Path:/app/Web/_Resources/Persistent/ BaseUri:_Resources/Persistent/ Bucket: KeyPrefix:}}'
     INFO  Extracting ALL resources for FileSystemTarget (path=/app/Web/_Resources/Persistent/, baseUri=_Resources/Persistent/)
     [1/3] ██████████████████████                                           33% | 4

spanic: runtime error: slice bounds out of range [:2] with length 1

    goroutine 1 [running]:
    github.com/sandstorm/synco/pkg/frameworks/flowServe.flowServe.extractAllResourcesFromFolder.func1({0xc005500a50, 0x41}, {0x9758f8?, 0xc005506270?}, {0x0?, 0x0?})
        github.com/sandstorm/synco@v1.2.0/pkg/frameworks/flowServe/flowServe.go:309 +0x4ea
    path/filepath.walk({0xc005500a50, 0x41}, {0x9758f8, 0xc005506270}, 0xc00029b918)
        path/filepath/path.go:480 +0x116
    path/filepath.walk({0xc00021f6c0, 0x1f}, {0x9758f8, 0xc0000ab6c0}, 0xc00029b918)
        path/filepath/path.go:504 +0x26f
    path/filepath.Walk({0xc00021f6c0, 0x1f}, 0xc00029b918)
        path/filepath/path.go:571 +0x6c
    github.com/sandstorm/synco/pkg/frameworks/flowServe.flowServe.extractAllResourcesFromFolder({}, 0xc20a60?, {0xc00021f6c0, 0x1f}, {0xc0002841c8, 0x16})
        github.com/sandstorm/synco@v1.2.0/pkg/frameworks/flowServe/flowServe.go:279 +0xc7
    github.com/sandstorm/synco/pkg/frameworks/flowServe.flowServe.Serve({}, 0xc0000b2780)
        github.com/sandstorm/synco@v1.2.0/pkg/frameworks/flowServe/flowServe.go:172 +0x41b
    github.com/sandstorm/synco/pkg/serve/cmd.glob..func1(0xc22740?, {0x8b92db?, 0x2?, 0x2?})
        github.com/sandstorm/synco@v1.2.0/pkg/serve/cmd/source-cmd.go:61 +0x4da
    github.com/spf13/cobra.(*Command).execute(0xc22740, {0xc0000b8940, 0x2, 0x2})
        github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
    github.com/spf13/cobra.(*Command).ExecuteC(0xc22460)
        github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
    github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.6.1/command.go:968
    github.com/sandstorm/synco/lite/cmd-lite.Execute()
        github.com/sandstorm/synco@v1.2.0/lite/cmd-lite/root-lite.go:45 +0x51
    main.main()
        github.com/sandstorm/synco@v1.2.0/lite/main-lite.go:8 +0x17
klfman commented 1 year ago

The line in synco that throws the error is: resourceFilesIndex["Resources/"+resourceSha1[0:1]+"/"+resourceSha1[1:2]+"/"+resourceSha1[2:3]+"/"+resourceSha1[3:4]+"/"+resourceSha1]

Could this be related to a breaking change in Neos 5.0 where the hash path segments in the pubic resource folder were reorganized?

https://docs.neos.io/api/upgrade-instructions/4/upgrade-instructions-4-3-5-0 section Settings subdivideHashPathSegment and relativeSymlinks enabled by default

The project is running Neos 7.0, but flow configuration:show shows that subdivideHashPathSegment: false is set in my project.

Looking at Neos/Flow/ResourceManagement/Target/FileSystemTarget.php there is a respective example that makes me think that: "c/8/2/8/c828d0f88ce197be1aff7cc2e5e86b1244241ac6/MyPicture.jpg" (if subdivideHashPathSegment is on) or "c828d0f88ce197be1aff7cc2e5e86b1244241ac6/MyPicture.jpg" (if it's off)

skurfuerst commented 1 year ago

@klfman I uess you are right :) Thanks, we can add support for it :)