clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

FileStorage->next() doesn't work from the first record

Open ssnepenthe opened this issue 4 years ago • 1 comments

Seems like this is probably related to #510.

FileStorage->next($id) fails to load anything when $id is the ID of the oldest/first metadata file available.

To reproduce create a fresh laravel install with clockwork, visit the site and refresh a couple of times.

Check the storage/clockwork directory, note the id of the first metadata file and visit __clockwork/{id}/next.

The result should be a list of metadata records starting from the second oldest record but instead we get an empty array.

Screen Shot 2021-08-04 at 10 50 21 AM Screen Shot 2021-08-04 at 10 50 51 AM

ssnepenthe avatar Aug 04 '21 17:08 ssnepenthe

Hey, thanks for the report!

This is indeed an issue with how we read entries from the index file.

When seeking forward in the index we use a method called FileStorage::readNextIndex, which literally reads the next line from the index. This is what we want at all times.. except when we are right at the start of the file there is no previous line, so the first line of the file always gets skipped.

Will probably leave this for the 6.0 release cycle, since the index handling code is pretty finicky and it's a pretty niche edge case.

itsgoingd avatar Aug 04 '21 21:08 itsgoingd