Changeset 652 in code for trunk/contrib


Ignore:
Timestamp:
Oct 18, 2021, 5:15:15 PM (4 years ago)
Author:
contact
Message:

Add context args to Database interface

This is a mecanical change, which just lifts up the context.TODO()
calls from inside the DB implementations to the callers.

Future work involves properly wiring up the contexts when it makes
sense.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contrib/znc-import.go

    r620 r652  
    33import (
    44        "bufio"
     5        "context"
    56        "flag"
    67        "fmt"
     
    8081        }
    8182
    82         l, err := db.ListUsers()
     83        l, err := db.ListUsers(context.TODO())
    8384        if err != nil {
    8485                log.Fatalf("failed to list users in DB: %v", err)
     
    112113                u.Admin = section.Values.Get("Admin") == "true"
    113114
    114                 if err := db.StoreUser(u); err != nil {
     115                if err := db.StoreUser(context.TODO(), u); err != nil {
    115116                        log.Fatalf("failed to store user %q: %v", username, err)
    116117                }
    117118                userID := u.ID
    118119
    119                 l, err := db.ListNetworks(userID)
     120                l, err := db.ListNetworks(context.TODO(), userID)
    120121                if err != nil {
    121122                        log.Fatalf("failed to list networks for user %q: %v", username, err)
     
    184185                        n.Enabled = section.Values.Get("IRCConnectEnabled") != "false"
    185186
    186                         if err := db.StoreNetwork(userID, n); err != nil {
     187                        if err := db.StoreNetwork(context.TODO(), userID, n); err != nil {
    187188                                logger.Fatalf("failed to store network: %v", err)
    188189                        }
    189190
    190                         l, err := db.ListChannels(n.ID)
     191                        l, err := db.ListChannels(context.TODO(), n.ID)
    191192                        if err != nil {
    192193                                logger.Fatalf("failed to list channels: %v", err)
     
    218219                                ch.Detached = section.Values.Get("Detached") == "true"
    219220
    220                                 if err := db.StoreChannel(n.ID, ch); err != nil {
     221                                if err := db.StoreChannel(context.TODO(), n.ID, ch); err != nil {
    221222                                        logger.Printf("channel %q: failed to store channel: %v", chName, err)
    222223                                }
Note: See TracChangeset for help on using the changeset viewer.