 Datastore = remote.require "nedb"
 
 angular.module 'gummyApp'
-    .controller 'MainCtrl', ($scope, $rootScope, $timeout, $trakt, $rotten) ->
+    .controller 'MainCtrl', ($scope, $rootScope, $timeout, $q, $trakt, $rotten) ->
 
 
         ###*

                # dots in name)
                filename = filename.join " "

                # Find movie infos
                $trakt
                    .search filename
                    .then (data) ->

                        # Add filepath to db
                        movie = data[0]
                        movie.path = file.path

                        # Save data to DB
                        $scope.db.insert movie, (e, item) ->
                            if e then return console.error e

                            # Add data to main grid
                            $scope.add_movie movie


                    .catch (e) ->
                        console.error e


        ###*
         # Add a movie and getting rid of angular fucking digest cycle
        ###
        $scope.add_movie = (movie) ->
            $timeout () ->
                $scope.grid.push movie



        #$scope.check = (filepath) ->

        # Init app
        $scope.init()


            for file in files

                # Check for ext
                filename = file.name.split(".")
                ext = filename.pop()
