You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: file_info_store.go
    path of file: ./repos/mattermost/server/channels/store/sqlstore
    
    the code of the file until where you have to start completion: // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

package sqlstore

import (
	"database/sql"
	"fmt"
	"regexp"
	"strconv"
	"strings"

	sq "github.com/mattermost/squirrel"
	"github.com/pkg/errors"

	"github.com/mattermost/mattermost/server/public/model"
	"github.com/mattermost/mattermost/server/public/shared/mlog"
	"github.com/mattermost/mattermost/server/public/shared/request"
	"github.com/mattermost/mattermost/server/v8/channels/store"
	"github.com/mattermost/mattermost/server/v8/einterfaces"
)

type fileInfoWithChannelID struct {
	Id              string
	CreatorId       string
	PostId          string
	ChannelId       string
	CreateAt        int64
	UpdateAt        int64
	DeleteAt        int64
	Path            string
	ThumbnailPath   string
	PreviewPath     string
	Name            string
	Extension       strin
    
func (fs *SqlFileInfoStore) GetUptoNSizeFileTime(n int64) (int64, error) {
	if n <= 0 {
		return 0, errors.New("n can't be less than 1")
	}

	var sizeSubQuery sq.SelectBuilder
	// Separate query for MySql, as current min-version 5.x doesn't support window-functions
	if fs.DriverName() == model.DatabaseDriverMysql {
		sizeSubQuery = sq.
			Select("(@runningSum := @runningSum + fi.Size) RunningTotal", "fi.CreateAt").
			From("FileInfo fi").
			Join("(SELECT @runningSum := 0) as tmp").
			Where(sq.Eq{"fi.DeleteAt": 0}).
			OrderBy("fi.CreateAt DESC, fi.Id")
	} else {
		sizeSubQuery = sq.
			Select("SUM(fi.Size) OVER(ORDER BY CreateAt DESC, fi.Id) RunningTotal", "fi.CreateAt").
			From("FileInfo fi").
			Where(sq.Eq{"fi.DeleteAt": 0})
	}

	builder := fs.getQueryBuilder().
		Select("fi2.CreateAt").
		FromSelect(sizeSubQuery, "fi2").
		Where(sq.LtOrEq{"fi2.RunningTotal": n}).
		OrderBy("fi2.CreateAt").
		Limit(1)

	query, queryArgs, err := builder.ToSql()
	if err != nil {
		return 0, errors.Wrap(err, "GetUptoNSizeFileTime_tosql")
	}

	var createAt int64
	if err := fs.GetReplicaX().Get(&createAt, query, queryArgs...); err != nil {
		if err == sql.ErrNoRows {
			return 0, store.NewErrNotFound("File", "none")
		}

		return 0, errors.Wrapf(err, "failed to get the File for size upto=%d", n)
	}

	return createAt, nil
}